Yeah there are two options;
- We either centralise all of the mutable static globals and make that thread local
- We make all mutable static globals __thread static so that they are thread local
1 messages · Page 2 of 1
Yeah there are two options;
On a different note, the code coverage for the msc and net class fuzzers is not fantastic and i might be missing something in my fuzzing stubs. I'm going to take a closer look over the next couple of days, but if you've got time to take a quick look at the fuzz harnesses/callbacks that would be fantastic.
Describe the PR
Currently the AFL fuzzing engine makes the assumption that it can run a library in multiple threads without any shared state. To make this assumption consistent with tinyusb we need to make static globals thread local when fuzzing.
Additional context
Discussed here:
https://github.com/hathach/tinyusb/issues/1715#issuecomment-1396436517
Actual issue here (see stability)
https://oss-fuzz.com/fuzzer-stats?project=tinyusb&fuzzer=afl&job=afl_asan_tinyusb&group_b...
this is a good idea; but i'd use a single uint64_t to do the tracking and some basic bit ops (you are using 8x the memory and don't seem to make use of the difference between 0xff and the item start) other than for an assertion.
but we still need to track the allocation size. if we uses bitmask, we may need to add the buf size to endpoint structure.
Hello,
I can confirm this bug occurs also in Windows 10 and the RP2040 (Raspberry pi pico)
Update the code change to use uint64_t to track the allocation status. Calculate allocation size when free. Put the size calculation into a new static function to make sure we have the same logic when allocating and free.
The reason i suggested using a uint64_t was to use bit operations rather than a bunch of loops; e.g. something like:
uint block_count = size / 64;
uint64_t block_mask = (1ull << block_count) - 1;
for (size_t start = 0; start < DPRAM_BLOCKS - block_num; start++) {
if (!(dpram_state & block_mask)) {
start_block = start;
dpram_state |= block_mask;
}
block_mask <<= 1;
}
FYI Cortex-M0 is very inefficient with bitwise operations, in addition uint64_t is not a native data type which needs runtime support like ABI I64Shl to do math operations.
So it's better to compare the assembly output before decide which method is better :)
When tools/top.mk finds it is running on Windows, it expects SHELL set to cmd.exe.
Some Windows development environments invoke a mingw version of gnu make with SHELL set to /bin/sh or /bin/bash (either explicitly or by default), in which case tinyUSB make fails when a $(shell...) command feeds DOS syntax to sh. We can't just use sh, as many Windows environments won't have unix utilities like realpath (used by this makefile for sh shell commands).
This fix forces SHELL=cmd.exe on Windows ...
I've addressed the review comments and updated the PR but unfortunately it looks like the SOF interrupt has to be constantly enabled. I cache the time of the previous SOF event and compute delta modulo 1000, but this will fail after several seconds as it appears there is enough clock drift to push the software blanking period away from the critical period.
We have no other way of keeping a stable count of where we are in a frame without logging every interrupt so whenever a bulk IN endpoin...
if we want to unconditionally set it to 1, we should probably #undef it first
maybe consider making this a macro that returns 0 when !TUD_OPT_RP2040_USB_DEVICE_UFRAME_FIX rather than having an external function that always returns false.
looks like indent here is wrong
should this be in the if (en) branch
since your here, how about moving active from above with suitable comment into this group of 1 byte fields... we have 32 of these structures and we were wasting 4 bytes per.
The whole file uses 2 and 4-space indents interchangeably throughout, but yes it looks off
Yes, compilation will fail if someone's set this already
(gdb) ptype /o struct hw_endpoint
/* offset | size */ type = struct hw_endpoint {
/* 0 | 1 */ _Bool configured;
/* 1 | 1 */ _Bool rx;
/* 2 | 1 */ uint8_t ep_addr;
/* 3 | 1 */ uint8_t next_pid;
/* 4 | 4 */ io_rw_32 *endpoint_control;
/* 8 | 4 */ io_rw_32 *buffer_control;
/* 12 | 4 */ uint8_t *hw_data_buf;
/* 16 | 1 */ _Bool active;
/* XXX 1-byte hole */
/...
ah, ok, i thought it would make it smaller, but i was thinking of the 2 uint16_t s as being 4 byte aligned for some reason :-(
which i think they may have
In host mode the two extra fields end up growing the structure to 36B, so it is worth rearranging so that pad bytes at the end of the structure get used instead.
ah thanks for the tip, currently I have an issue with IAR assembler. Since freeRTOS for IAR have asm file, however, IAR assembler does seems to have limited support for preprocessor. I cannot handle the tusb_option.h include especially the TU_CHECK_MCU(). Anyway, I will try to find an walkaround to for FreeRTOSConfig.h without the need to include tusb_config.h
Describe the PR
GPIOE was turned on twice, changed to missing GPIOF.
GPIOI is not present on all boards notably STM32H723
so clock in turned on only if present.
Add support for nucleo-h723zg
Mostly copy of stm32h743nucleo.
Linker script generated by STM32CureIDE.
Since this device has only one HS USB, board.h contains few defines that map on
board HS USB to FS because there is no ULPI chip mounted on Nucleo board.
Additional context
@kilograham can you approve the workflow? so that I can verify build
RaspberryPi OS
RP2040
examples/host/cdc_msc_hid
I am trying to use a Pico as USB Host to and Arudino Due for a USB Serial Connection. When data is sent, an assertion fails. While the below says the assertion fails on line 484, it is actually line 481. The difference is due to some additional logging statements added by me.
Build examples/host/cdc_msc_hid on pico and load onto pico.
Connect usb c...
Describe the PR
Adds a seed corpus for the fuzzer based on real USB packets captured using wireshark.
Additional context
By default, a fuzzer will try to randomly search for inputs that increase code coverage. In some cases this can take a really long time for the fuzzer to "learn" the structure of a protocol. One approach to mitigate this problem is to give the fuzzer a good starting point, with ...
thank you for the PR, I have pushed some update to suppress warnings from system_.c and fix the typo. Everything looks great now.
Thank you for the PR and sorry for the delay. I still haven't set up my PC to actually compile ft90x port yet. Therefore I could only review the code-only, it looks good except for the include of tinyprint.h whose path is missing from family.mk. Please double check.
"tinyprintf.h" is included but its path ($(TOP)/$(FT9XX_SDK)/3rdparty/tinyprintf" is not added to INC +=. I still haven't compile with ft90x yet, please double check to see if path is needed.
@HiFiPhile IAR Assembler preprocessor is rather limited and does not seems to support variadic macro. This becomes an issue with freertos example where portasm.s include FreeRTOSConfig.h which in turn include "tusb_option.h". I have send an support request to IAR. Though is there any chance that you an walkaround (maybe I miss an IAR compiler/assembler option).
#define TU_ARGS_NUM(...) _TU_NARG(_0, ##__VA_ARGS__, _RSEQ_N())
--------------------^
"/home/hathach/code/tinyusb/src/c...
I got this "working" by adding the following to tu_edpt_bind_driver
ep2drv[tu_edpt_number(0x83)][tu_edpt_dir(0x83)] = driver_id;
ep2drv[tu_edpt_number(0x04)][tu_edpt_dir(0x04)] = driver_id;
Obviously this isn't the correct fix, but at least gives me something to work with for now.
I can see that endpoint addresses 04 and 83 aren't being found by this function, even though they are returned during the parsing of the configuration descriptor.
TUSB_DESC_ENDPOINT = 5, tu_desc_typ...
Describe the PR
This PR add support for IAR build with self-hosted ci hosted by @HiFiPhile. Initial port includes stm32 f0, f1, f4, f7. It is almost complete except for freeRTOS example where portasm.c (in the freeRTOS kernel) include FreeRTOSCOnfig.h which in turn include the tusb_option.h. Initially I thought the IAR Assembler cannot handle complicated macros, however, It look more like the issue is including C header file inside an .s file.
I have only used the assembler for basic things such as copy vector table to ram.
It seems only thing needed by port.asm is configPRIO_BITS, is it possible to wrap other things by
#ifndef _ _IAR_SYSTEMS_ASM_ _ ?
I have only used the assembler for basic things such as copy vector table to ram.
It seems only thing needed by port.asm is
configPRIO_BITS, is it possible to wrap other things by#ifndef _ _IAR_SYSTEMS_ASM_ _?
@HiFiPhile let me move the discussion here to make it easier to follow. Indeed, I just figured it out, that including C header in the .s file is the root cause (after trying to conform with IAR Assembler). configPRIO_BITS is unfortunately defined within mcu header such...
superb! thank you for your PR, I made a minor clean up on the comment. Haven't tested it on windows machine, but look good
Yes, indeed. Sorry, that file was used for debugging and was included in recent work on the sdk as you found. It's not required in TinyUSB and I've updated the PR to reflect this and tested against the latest code.
no problem at all, this is why including port build in the ci is important. We should try to this in the future. ( I still need to get my PC setup to give this port a try).
look good now, thank you for the PR and your patient
Thanks! Dumb question though: We all hate comment syntax in make and shell that essentially prohibits space before comment # mark. But, I put the following on one line so that it would be easy to see when someone greps for CMDEXE to find out it's exact meaning. So, sorry for the question, why did you break it into multiple lines?
Thanks again for your great work!
Best Regards, Dave
CMDEXE := 1# makefile shell commands should use syntax for DOS CMD, not unix sh
it is just my personal preference, I found having the inline comment for makefile not as readable as one line above the actual command.
Thank you very much for the PR and your patient. I still haven't got time to tried this out on actual hardware described with Errata 15 (with Pi4 USB Hub). But it looks great now.
I have made some minor changes mostly whitespace, rename, and minor refactor. Let me know these changes made sense to you. If all is good, I think we could merge this as it is.
please put the debug log into txt file for readability
Describe the PR
this should be fixed by #1877 please try to pull the PR changes to see if that works for you.
@hathach I think your comments mentioning "walkaround" / "walk-around" should actually say "workaround" ?
@hathach I think your comments mentioning "walkaround" / "walk-around" should actually say "workaround" ?
Indeed, that is my bad
I have no objections to the edits.
I have no objections to the edits.
perfect !! Thank you very much, merged now. Feel free to make more follow up PR should this needs more changes to fix.
Others
STM32H7 Custom
STM32H7 using TinyUSB github master pulled on the 2022-05-24.
FreeRTOS 202210.00 .
Main use is two CDC ports.
I'm having occasional random problems with tu_edpt_claim() stalling due to the passed mutex never being unlocked.
tu_edpt_claim() is being called up the chain from a tud_cdc_n_write_flush() in a FreeRTOS static task with low priority.
tud_task() is run from a task with the highest priorit...
Is there a list showing which esp-idf version works with which tinyusb version
closed firmware is not reproducible and therefore not trouble-shootable. If you think the issue is caused by the mutex, please try to provide an simplest example that could reproduce the issue.
closed firmware is not reproducible and therefore not trouble-shootable. If you think the issue is caused by the mutex, please try to provide an simplest example that could reproduce the issue.
This shouldn't be closed yet. I can troubleshoot it with some help.
At some point in TinyUSB, the mutex is not being released, so on the next attempt to lock it, the lock function never returns as it's called with no-timeout (forever).
There are two problems here:
1 - the mutex is not relea...
reproducible code/example is required for a bug template, if you want to discuss/question please use the discussion ticket instead.
Describe the PR
IAR Build on self-hosted taking too long (~20mins), reduce the iar build to only family with different enough architecture/usb controller. Also update hardware test on self-hosted to download artifacts to reduce compile time for L4
Didn't know it took such long time. Is it compile time or clone sdk ?
Didn't know it took such long time. Is it compile time or clone sdk ?
Checkout sumodule take about 30s or so, each build takes 2 minutes for each matrix. Actually, I think the issue is due to the matrix. Matrix scale well with a farm of PC. In our case it hurt the self-hosted since it run one after another on 1 instance. Let me try to bundle several family in 1 run, it would possible reduce the time to run
Let me try to bundle several family in 1 run, it would possible reduce the time to run
Yes I saw CPU usage is quite low.
Just doubled assigned RAM & Core, after reboot it should be quicker :)
bundled everything, the build time only takes 11 minutes now.
https://github.com/hathach/tinyusb/actions/runs/4063998654/jobs/6996895275
If the cpu usage is still low, it is probably due to my build_family.py script that doesn't do parallel enough. Though it is reasonable for now
Just doubled assigned RAM & Core, after reboot it should be quicker :)
that is great, I trigger rebuild to see if we got it faster :)
Describe the PR
This PR adds support for DshanMCU Pitaya Lite and Blue Pill boards with MM32F3273 cpu.
Additional context
I have experimented with tinyusb on:
tinyusb works, but care has to be taken to choose the correct SYSCLK_FREQ.
For the MM32F3273 with a 12 MHz crystal, in ``tinyusb/hw/mcu/mindmotion/mm32sd...
Others
RP2040-Zero
Minimal example code which demonstrates my issue:
#include
#include "pico/stdlib.h"
#include "tusb.h"
#include "bsp/board.h"
void tuh_hid_mount_cb(uint8_t dev_addr, uint8_t instance, uint8_t const* desc_report, uint16_t desc_len) {
tuh_hid_receive_report(dev_addr, instance);
}
void tuh_hid_umount_cb(uint8_t dev_addr, uint8_t instance) {
}
void tuh_hid_report_received_cb(uint8_t dev_addr, uint8_t instanc...
Describe the PR
Well, it's not a solution at all, but if I change the main loop in my test to be:
for(;;) {
tuh_task();
sleep_ms(10);
}
It appears to "work" without CFG_TUSB_DEBUG being set to 2 or higher... I haven't verified the actual data yet, but it looks vaguely how I'd expect it to.
This was after determining that the log line which seemed to affect the timing enough for things to work was in hidh_xfer_cb() (in class/hid/hid_host.c); specifically:
...
Describe the PR
My fix in dhcpserver.c for some DHCP clients (#1712) accidentally introduced a potential DoS vulnerability: In case a DHCP-packet WITHOUT DHCP_MESSAGETYPE was received, the code jumped out of the function without freeing the pbuf as it is required. When enough such messages are received, not pbufs are available anymore to handle traffic and the system might not be able to receive any more packets.
This PR fixes the problem by properly free()ing the pbuf in case no `DHC...
GCC deals with it inline, so it is a bit better (smaller in debug mode, but slightly larger in release mode)
The intention here was to save RAM (8 bytes vs 64), however I do agree that perhaps it is undesirable in general to have much of any increase in code size since this feature is something most be clearly don't need (their endpoint use is largely static)
I therefore suggest we #ifdef this new code
i pushed a change to change optimization to -Os for hw_endpoint_init which was pointlessly being generated 3 times.
The comment doesn't match the line below.
Does it fail with gcc 12+ (as the comment suggests) or with 11.3+ as the line below and your explanations in this PR suggest it?
Describe the PR
Defined tuh_hid_send_report using ep_out defined in hidh_interface_t structure.
Additional context
I assume tuh_hid_send_report was originally not defined because hidh_open was incomplete. I don't see any reason why it shouldn't be defined now, so I took a stab at it. I tested it on an RP2040 by sending vibration to a Dualshock 4 HID controller on its OUT endpoint, 3.
How was the fix for line 435 in cdc_device.c tested?
We currently see no issues with the code as it was previously.
Yes, I am familiar with C and pointers. What I have noticed is that when changes are made, there aren’t a lot of comments as to what was changed and why.
Was hoping to however made the change would put those comments here.
I use tinyusb and most of the changes that I see do not have consequences for usability.
I don't understand your point. This is bug/typo and as mentioned, it should crash previously in my opinion but it doesn't (pure luck). The code speaks for itself, what else I should put the comment for ?
I use tinyusb and most of the changes that I see do not have consequences for usability.
Then don't upgrade if you have no need for those changes.
Sorry for the churn on this. I thought it would be useful to include use of tuh_hid_send_report() in example code. In the example, pressing the left and right triggers should control the left and right motors respectively. I don't plan on pushing anything further.
Describe the PR
Bump up version for 0.15.0 release
Linux
n/a
examples/device/cdc_msc
Compilation under sdcc (4.0 and 4.2) fails on the assert at line 414 of cdc.h which checks the size of cdc_line_control_state_t. The exact layout of bitfields is apparently implementation-defined and sdcc makes a different choice than gcc in this case. See the SDCC discussion for more info. So this seems to be a kind of C standard conformance ...
sdcc also rejects bitfields larger than 16 bits; the PR will cover that as well
The open-source SDCC compiler has many limitations, but I have managed, after considerable hacking, to compile TinyUSB with it. This is one issue that I think is legitimately universal: compiler-specific assumptions about bitfield alignment which are implementation-defined per the Standard. Please see the discussion with the SDCC maintainers.
Describe the PR
This PR tweaks some reserved bitfields so the assumptions made elsewhere in the c...
Linux
mimxrt1010_evk
As far as I can see, everything is broken.
examples/device/msc_dual_lun, as an example is definitely broken.
commit 19768936ae6379b4c86947f70ab5cf2c0f8ed8f4 completely breaks the USB on the mimxrt1010. It appears that it is a problem in the SDK that was updated. Validating that now.
# git checkout 19768936ae6379b4c86947f70ab5cf2c0f8ed8f4
# git submodule update hw/...
I have further "narrowed" the problem to commit c84411fd of mcux-sdk.
Narrowed is in quotes because it's a wholesale update of the SDK, so it's not trivial (for me anyway) to see where the issue is.
Upon further investigation, it appears that the SDK broke enabling the DCACHE on the 1011. Not sure if that was intentional, but if you apply this diff, everything works again:
diff --git a/devices/MIMXRT1011/system_MIMXRT1011.c b/devices/MIMXRT1011/system_MIMXRT1011.c
index 3db75178..5adf5339 100644
--- a/devices/MIMXRT1011/system_MIMXRT1011.c
+++ b/devices/MIMXRT1011/system_MIMXRT1011.c
@@ -116,6 +116,11 @@ void SystemInit (void) {
SCB_EnableICache();
}
#endif...
Strangely, they took out enabling the DCache on all the i.MX RTs. However, the 1062 still works (I verified that), but the 1010 is broken. Not sure what's up with that.
Thanks for your confirmation
Linux
Pico
examples/hosts/cdc_msc_hid modified to receive 512 + 1 bytes. (originally receives 64 + 1 bytes)
This is not a bug in tiny usb, but rather the Arduino Due. It reports as a Full Speed device, but reports a max packet size of 512. It also sends with a 512 byte packet size. The following patch allows tinyusb to communicate with the due in host mode. It modifies the max packet size from the descriptor from 512 bytes...
MacOS
Nucleo F413ZH
examples/audio_test
I added tinyusb to my CubeIDE project (which worked mostly flawlessly). Then I tried some of the examples. Both audio examples refused to work, while cdc_dual_ports and midi_test worked without any problems. I have another project, where I use STM's default USB middleware and there I can implement a working USB audio device; I also copied over the clock settings from this project in ...
after further investigation I think this is related to the fact that the Nucleo onboard OTG port is only capable of USB FS, wheres USB AUDIO 2.0 requires HS, if I'm not mistaken
wheres USB AUDIO 2.0 requires HS, if I'm not mistaken
It's not case.
Could you try #1825 ?
I tried it, but unfortunately, this does not fix my issue
Please enable debug logging in tusb_config.h and upload log.
You can also try F412 BSP in https://github.com/hathach/tinyusb/tree/master/hw/bsp/stm32f4/boards/stm32f412nucleo
normally they have the same USB IP.
Thanks for coming back to me!
I set debug level to 3 and hooked up tu_printf to an UART. Here's what I got when plugging the device in:
USBD init on controller 0
sizeof(usbd_device_t) = 43
sizeof(tu_fifo_t) = 12
sizeof(tu_edpt_stream_t) = 24
AUDIO init
USBD Bus Reset : Full Speed
USBD Setup Received 80 06 00 01 00 00 40 00
Get Descriptor Device
Queue EP 80 with 18 bytes ...
USBD Xfer Complete on EP 80 with 18 bytes
Queue EP 00 with 0 bytes ...
USBD Xfer Complete...
Please use unmodified example, your are missing tud_audio_get_req_entity_cb() in exaplem's main.c
oh sorry for the confusion... I forgot to re-enable the resp. source file. But that is not the issue, it does not work either way. I updated the log above to what's being reported when tud_audio_get_req_entity_cb() and the other callbacks are enabled. I also checked with a breakpoint and the said function was definitely called when I collected the updated log data above
I tried the UAC2 headset example and this seems to work (at least partly).
I got two runtime assertions in dcd_synopsis.c;
TU_ASSERT(sz + _allocated_fifo_words_tx <= EP_FIFO_SIZE/4); failedbut I can stream audio to the device and record it back :-) The recorded audio is a bit corrupted, which I'll investigate now. But still this is a huge step forward for me
I fact I get loads of assertions with the headset example... I took a chance and commented some of them out just to see if it works in principle; however, finnaly I got this:
usbd_class_driver_t const * driver = get_driver( _usbd_dev.ep2drv[epnum][ep_dir] );
TU_ASSERT(driver, );
in usbd.c, which of course cannot be skipped...
This fixes https://github.com/hathach/tinyusb/issues/1894. I'm not really sure if this is the correct way to fix it, and I have not tested on all the rest of the family members, however, this lets the i.MX1010 work again.
The problem: the latest SDK update does not enable the data cache by default This causes an assert in board_init() when attemping to control clock gating. I haven't investigated further as to why it's a problem, but it is a problem.
Describe the PR
This PR so...
No you touch asserts they exists for a reason !
If you got USBD asserts their is something seriously wrong in your side.
You said you excluded dcd_synopsis.c (which is good to use dwc2.c) how did you hit assert inside it?
there are two synopsis folders, one portable/st/synopsis and one portable/synopsis. The latter seems to be deprecated (at least that's what I read in another report) and would generate compile errors and / or duplicate symbols for me.
And, I would never leave the assertions commented out, I just wanted to see if it works at all. I know they're there for a reason :-)
only a typo in arithmetic
2+16+4 = 22, last one should be 8
can you specify which board/mcu you are using, if possible please add an PR to include the mcu into board support, so that we could include the SDCC into ci build to fix any future changes.
How embarrassing! I changed it at the last minute and got it wrong :(
This will eventually be for the (obsolete) ALi M5623 in certain Canon scanners; I am in the process of porting to SDCC but am facing code size issues that require significant changes to the TinyUSB core so a PR is somewhat in the future.
great, thank you for the fix
Describe the PR
Add adafruit metro m7 1011
thank you for the info, indeed the code size has been increased quite a bit lately due to lots of added features. Maybe in the future we should have some option to trim down the code size e.g no dynamic configuration etc..
look great thank you for the fix :)
host/cdc_msc_hid to see if that works for you.Class Driver
Any
No problem, just ideas.
Since all interface is determined upon connection, dynamic configuration is not possible (I think?). However, if the device can emulate a hub and can then maybe we can connect more devices to this hub to do dynamic configuration on the fly.
Not entirely sure how practical this but just throwing an idea for a potential feature,
OK tried that; exactly the same issue.
Here are the log reports from the cdc_msc_hid example, at three different debug levels - the last one so you can see the HID report bytes.
With each run I move the joystick in a way which should affect the first byte (containing part of the 10-bit X axis), but the first byte is always zero.
CFG_TUSB_DEBUG == 1
TinyUSB Host CDC MSC HID Example
HID device address = 1, instance = 0 is mounted
HID Interface Protocol = None
HID has 1 r...
please ATTACHED log as txt file for readibitly
Describe the PR
update pico-pio-usb to include data pid fix (0.5.1)
Describe the PR
On some devices (this was found on the EA LPC4088 Developer's Kit) the done list can become corrupted unless the WDH interrupt is disabled during processing.
I wouldnt have thought that should be require in IRQ context, but the OHCI spec does disable master interrupts during interrupt servicing
https://ia801603.us.archive.org/4/items/hcir1_0a/hcir1_0a.pdf From page 80.
//
// It is our interrupt, prevent HC from doing it to us again until we are finished
//
DeviceData->HC->HcInterruptDisable = MasterInterruptEnable;
Then at the end
DeviceData->HC->HcInterruptEnable = MasterInterruptEnable;
Perhaps we should be do...
Thanks for the link to the OHCI spec - I'd misplaced my copy and couldn't easily find another at the time.
As expected, replacing the WDH disable/enable with MIE disable/enable over the entire interrupt handler results in the same fixed behaviour on my board.
Looking at the issue again it's possible to resolve it without disabling interrupts (MIE or WDH) by writing 0 to HccaDoneHead once the list has been reversed (the example in the spec on page 82 shows it after processing the done li...
Others
Raspberry Pi Pico
https://github.com/rppicomidi/pico-usb-midi-processor
I am developing a new processor class for my project. When I call tud_midi_n_stream_write() to write a system exclusive message to cable 1 instead of cable 0, the message is sent to cable 0.
You can see by inspection of the code near lines 290...
sure please submit a PR if possible.
btw I have a open PR for a bunch of OHCI tweaks and fixes. Its getting a bit behind master and I should rebase it but it might be worth having a look.
https://github.com/hathach/tinyusb/pull/1491
Describe the PR
This pull request fixes #1909 by using the cable_num field in the first byte where appropriate.
Additional context
I tested this fix in this project.
Most likely, this is a problem within the RP2040 device controller driver (DCD), where the handling of the ISO EP may not be correct. This was at least the problem for other MCUs. The UAC driver is most likely not to blame, as it works for many MCUs. I did not investigate the RP2040 DCD however. The DCD is furthmore subject to improvements e.g. see #540. If you have time, please feel free to solve this issue and make PR! Thx in advance :)
Others
Raspberry Pi Pico
examples/device/uac2_headset with HID class from examples/device/hid_multiple_interface
Adding a HID or CDC class with the UAC2 example causes it to panic on Android Host. On Windows, the same thing occurs after an uncertain number of play and pauses. Setting CFG_TUSB_DEBUG=2 makes it panic on plugging in. Log and gdb indicates `assertion "hw_data_offset(next_buffer_ptr) <= USB_DPRAM_MAX" fai...
btw I have a open PR for a bunch of OHCI tweaks and fixes. Its getting a bit behind master and I should rebase it but it might be worth having a look. #1491
I saw this PR and gave it go to see whether it resolved this issue or not, but it did make the second root hub port on the LPC4088 work as well as the first.
Do you want to include this PR in yours to keep the OHCI fixes together in a single PR?
Do you want to include this PR in yours to keep the OHCI fixes together in a single PR
@wooyay Good idea. I have cherry picked your commit and merge it into my PR. I have maintained you as author of the commit ofcourse.
I also went ahead and rebased my PR against current master. If you wish to try it out let me know! a comment in #1491 would be good as it will improve confidence in the PR to help merge to master🤞
I also went ahead and rebased my PR against current master. If you wish to try it out let me know! a comment in #1491 would be good as it will improve confidence in the PR to help merge to master🤞
@Ryzee119 Great - I'll take a look and give it a go but it may not be until early next week. I can't see anything to be worried about but I'll leave a comment on #1491 either way and then close this PR.
@Ryzee119 I've given this PR a go and it's working on my EA4088 board with both OHCI root hub ports which is excellent.
I needed to make some changes for my environment (OPT_OS_NONE, gcc 10.3.1) to fix some compilation issues:
diff --git a/src/portable/ohci/ohci.c b/src/portable/ohci/ohci.c
index 76f97844c..cd747093a 100644
--- a/src/portable/ohci/ohci.c
+++ b/src/portable/ohci/ohci.c
@@ -35,7 +35,11 @@
//--------------------------------------------------------------------+...
Closing this PR as it's now included in #1491.
MacOS
Seeding Xiao
examples/device/audio_test
make: arm-none-eabi-gcc: No such file or directory
make: *** [_build/seeeduino_xiao/obj/src/portable/microchip/samd/dcd_samd.o] Error 1
Try to compile.
No response
No response
You should install the toolchain and add to PATH before compiling.
Hi, how would I do this? I followed the Quickstart guide, and its not working, and I am kinda new to using command console.
How do you add the tools to the path?
Current Macs use the Z Shell, so in your home directory there's a file called .zshrc (leading period is important). Edit that file to add the path to wherever the installer put the tools. Tho I think if you installed the tools from the [official ARM package]https://developer.arm.com/-/media/Files/downloads/gnu/12.2.rel1/binrel/arm-gnu-toolchain-12.2.rel1-darwin-arm64-arm-none-eabi.pkg?rev=495058480373470f98133166d00ff0c2&hash=45A682B78E26256ACBB7F13A972...
MacOS
lpcxpresso55s28
Any of the examples.
See here for details, but in a nutshell, the provided makefiles do not build the main.c and other files in the example source directory.
Clone the tinyusb project.
Change to the desired example project directory, e.g., /Users/andy/Projects/tinyusb/examples/device/midi_test
andy@mitzvah midi_te...
As a follow-up, I tested this on a Windows 10 box and I got a bunch of different warnings but the files in the example src directory compiled and the whole thing linked.
There must be a difference between whatever make program I have on my Windows box and whatever is provided by Apple in Xcode. If you look at the top of the transcript posted above, you see:
andy@mitzvah midi_test % make BOARD=lpcxpresso55s28 all
realpath: illegal option -- -
usage: realpath [-q] [path ...]
...
Windows 10
Gd32f470,usb fs register is same as gd32vf103
example/device/cdc_dual_ports
when use endpoint 0x83 as EPNUM_CDC_IN,usb print is ok.But use other endpoint ,only about 1000 byte can be printed correctly.The following data are all wrong.
void Usb_CdcSend(uint8_t *pbuf, uint32_t len)
{
uint32_t ret = 0;
tud_cdc_n_write_clear(0);
if (tud_ready())
{
ret = tud_cdc_write(pbuf, ...
thank you very much for your PR and sorry for the delay, I was too busy with other paid works. I back off a bit on using TU_STATIC, instead I would prefer to add _fuzz_thread as additional keyword. Even though it is a bit more verbose, the static keyword is more apparent to other user and easier to read.
I also rename macro FUZZ to _FUZZ to avoid if user application define it in the future .
Note: we could change _fuzz_thread to less verbose word in the future if you have any othe...
thank you for your PR. I made some changes to move the macro check to board.h to make it easier to follow
Personally I prefer to use TU_STATIC instead of adding _fuzz_thread keyword.
For most people who doesn't use fuzzing it's confusing what this keyword does, and I feel also the code is less neat putting a test keyword inside the stack.
For anyone who contribute they also need to learn what fuzzer does instead of copy TU_STATIC from existing code.
_fuzz_thread is __thread which is an actual keyword for thread_local (https://gcc.gnu.org/onlinedocs/gcc/Thread-Local.html#Thread-Local) . I was thinking to actual make use of it later on. Though you made the point, I think we should stick with tu_static instead.
Reverts hathach/tinyusb#1867
Describe the PR
follow up to #1867 with tu_static in lower case to mimic static keyword even though it is an macro
The definitions for MIDI_CIN_NOTE_ON and MIDI_CIN_NOTE_OFF are transposed in the header file.
brilliant !! Thank you very much for the PR and sorry for the huge delay. It is my bads, I should have reviewed this earlier. This add great improvement for ohci driver. I did some changes mostly rename to make it more consistent (in my pov):
@wooyay thanks for pointed out the issue with osal_task_delay(), though board_millis() cannot be used, since it is application function. We will do it better with additional API later on.
superb !! thank you for the PR, #1491 is merged now
Sorry for the churn on this. I thought it would be useful to include use of tuh_hid_send_report() in example code. In the example, pressing the left and right triggers should control the left and right motors respectively. I don't plan on pushing anything further.
not a problem at all, it is much better to demonstrate API usage with example. Sorry for being late on the review, I will try to review this as soon as I could. Just approve to get ci running (required by github for 1st time co...
Others
KA-NUCLEO-F411CE
src\class\cdc\cdc_device.c
I have described the issue in this post exactly: https://github.com/hathach/tinyusb/discussions/1923#discussioncomment-5099679
The problem in a nutshell, is that the 'epout_buf' and 'epin_buf" members of the 'cdcd_interface_t' struct should be allowed to have different sizes, that correspond to the rx_ff_buf and tx_ff_buf sizes consequently.
Hi, installed it from there but it didn't help. I have recently read the path recently changed, could that be the issue?
realpath: illegal option -- -
usage: realpath [-q] [path ...]
CC dcd_samd.o
make: arm-none-eabi-gcc: No such file or directory
make: *** [_build/seeeduino_xiao/obj/src/portable/microchip/samd/dcd_samd.o] Error 1
MacOS
Seeding Xiao
Audio_test
realpath: illegal option -- r
usage: realpath [-q] [path ...]
CC dcd_samd.o
make: arm-none-eabi-gcc: No such file or directory
make: *** [_build/seeeduino_xiao/obj/src/portable/microchip/samd/dcd_samd.o] Error 1
Trying to make the example
No response
No response
See the discussion here.
There are two issues here. The first is the error regarding realpath. These error appears when building on macOS. I didn't see it when building on a Windows machine using the GNU tools, especially make. This error hides the real problem.
The Makefile in each example directory has this line:
SRC_C += $(addprefix $(CURRENT_PATH)/, $(EXAMPLE_SOURCE))
and it is apparently...
Hi, I tried to do this, but unfortunately I am still getting the same error.
It seems like make.mk in shared examples directory makes this call, didn't forgive out why does it not work too
Hi, I have the same issue, tried your fix but its still broken.
superb !! Thank you very much for the PR and sorry again for the delay. memcpy_s is a great idea to prevent memory overflow, this function is new to me. I found an instance where ==0 is not checked, to prevent such as typo, I have change the code to 0==tu_memcpy_s(), this way it is easier to spot this type of issue.
Thank again for bringing this up.
Can someone please check this? The test seemed to fail due to an issue with the test harness
ci failed due to hw changes to self-hosted ci runner, don't worry about it for now. I will review this soon, look like we could have an merge easy. Thank you
This PR provides a small fix in SOF interrupt handling. SOF is not a flag of the GOTGINT register but of the GINTSTS register. Therefore the flag must be written in the GINTSTS register instead of the GOTGINT register to clear the interrupt.
Superb!! Sorry for huge delay, I am in the middle for reviewing this PR. Everything looks great, I am doing mostly clean up to make it more readable. Number of #ifdef in audio driver is starting to look scary now. We should do some refactoring in the future. Overall this PR is awesome and ready to merge, however there is a note in the review, that I think we should change to prevent a read out-of-bound of an array.
this would cause an read to out-of-bound for the memory. We should cast it to uin8_t* first before doing a read ?
No problem I know you are busy:) I'm on vacation I'll look at it later (I think I thought about out of bounds access)
Then dont worry about this, I can make changes myself, just want to confirm with you first
srcVal is already a uint8_t*, maybe you saw pdwVal ?
https://github.com/hathach/tinyusb/blob/8db462bf6e2cd6d244ab9b3a69471ad085478bf6/src/portable/st/stm32_fsdev/dcd_stm32_fsdev.c#L1218
oh right, sorry, I got confused and mixed-up, all is good then
everything looks good. Thank you very much for putting your effort to this brilliant PR.
Following how ST's CubeMX/CubeIDE tools generate RCC init structs and general best practice for usage of a struct like this, instances of RCC_ClkInitTypeDef, RCC_OscInitTypeDef, and RCC_PeriphClkInitTypeDef should all be initialized as empty with = {0};. I've confirmed that failing to do this in the stm32h723nucleo example causes some undefined behavior when implementing a TUSB stack on my own STM32H723 board (I didn't use the example directly but I lifted the contents of the
`board_...
Describe the PR
implemented by #1828
sorry for late response, I don't have the setup to test with, would you mind submitting a PR for this ?
A couple of CMake changes related to warnings, and some tiny code changes
This seems to be fixed in 0.15.0.
Linux
Custom, based on STM32F401RBT
My firmware is custom, and based on STM32CubeMX. It builds as a simple Makefile project.
The following steps were taken to include the tinyusb library and build it:
tinyusb as a submoduledcw2 component, as I understand that it supports the STM32F401Sources
...
Interesting, these Stall EP0 shouldn't happen. Have you tried stock example without modification ?
Have you tried other classes ?
For UAC class _audiod_fct[func_id].ctrl_buf_sz should be used instead of sizeof(_audiod_fct[func_id].ctrl_buf)
https://github.com/hathach/tinyusb/blob/34798ff85ec819bafc09da57f7853a1d116a7fff/src/class/audio/audio_device.c#L2293
I'm in vacation anyone can make a PR ? @silvergasp @hathach
#1935
Just tested the HID composite example, works fine.
[17504.035119] usb 1-1.3: new full-speed USB device number 27 using xhci_hcd
[17504.324266] usb 1-1.3: New USB device found, idVendor=cafe, idProduct=4004, bcdDevice= 1.00
[17504.324282] usb 1-1.3: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[17504.324294] usb 1-1.3: Product: TinyUSB Device
[17504.324305] usb 1-1.3: Manufacturer: TinyUSB
[17504.324316] usb 1-1.3: SerialNumber: 123456
[17504.429244] input: TinyUSB Ti...
I tried your suggested fix, but it runs into an assertion in dcd_dwc2.c:658:
if(dir == TUSB_DIR_OUT)
{
// Calculate required size of RX FIFO
uint16_t const sz = calc_grxfsiz(4*fifo_size, ep_count);
// If size_rx needs to be extended check if possible and if so enlarge it
if (dwc2->grxfsiz < sz)
{
>> TU_ASSERT(sz + _allocated_fifo_words_tx <= _dwc2_controller[rhport].ep_fifo_size/4);
// Enlarge RX FIFO
dwc2->grxfsiz = sz;
}
...
I tried your suggested fix in https://github.com/hathach/tinyusb/pull/1852#issuecomment-1455102835, but it runs into an assertion in dcd_dwc2.c:658
I think F411's USB FIFO is not enough for high-res format like 24bit/96kHz, could you try to reduce sample rate/bit res like how #define __RX__ did in tusb_config.h and main.c ?
So, I just added #define __RX__ which changes the point at which it locks up. It now runs into the default case of handle_rxflvl_irq with pktsts == 11 and hangs at TU_BREAKPOINT() in dcd_dwc2.c:1085.
However, I don't see the stalls anymore:
changes_log.txt
The log suddenly stops when I hit TU_BREAKPOINT().
Another piece of information: The STM32F401 has the same total FIFO size as all the other F4 series parts, namely 1280 bytes for the full speed port. It shouldn't be too small then.
I tested the 4-channel microphone example, and it somewhat works (only with your fix, replacing sizeof()).
Two channels show a sawtooth, two are empty.
Also, I had to drastically increase the level of the sawtooth, otherwise it appeared to be zero.
I increased the dataVal increment from 1 to 200.
// Generate dummy data
for (uint16_t cnt = 0; cnt < CFG_TUD_AUDIO_FUNC_1_N_TX_SUPP_SW_FIFO; cnt++)
{
uint16_t * p_buff = i2s_dummy_buffer[cnt]; // 2 bytes...
@hathach
I think there is an issue in dwc2 Rx FIFO allocation.
In uac2_headset example the max Rx packet size is 24(96+1) = 776 which can be hold in 1280 bytes FIFO.
However calc_grxfsiz(776, 4) will return 411 which is larger than FIFO size.
At least 2*(max_ep_size/4) seems wrong.
Bug: #1935
Describe the PR
There was a bug introduced in https://github.com/hathach/tinyusb/pull/1852#issuecomment-1455102835, that was filed in #1935. I'm hoping that this fixes the issue.
thank you @silvergasp and @HiFiPhile for fixing the issue
which is larger than FIFO size.
since this is in units of 32 bit words, right?
It says in the F401 reference manual:
Program the OTG_FS_GRXFSIZ register, to be able to receive control OUT data
and setup data. If thresholding is not enabled, at a minimum, this must be equal to
1 max packet size of control endpoint 0 + 2 words (for the status of the control
OUT data packet) + 10 words (for setup packets).
I don't see the calculation matching this, but it was probably de...
Describe the PR
should be fixed by https://github.com/hathach/tinyusb/pull/1938 , will merge shortly, check it out to see if that works for you
Windows 10
Pico
None involved
The inclusion of the CH32V307 hal in https://github.com/hathach/tinyusb/commit/949950e592d9a23a4b449784b0f8e7e274129318 has caused a CI failure in Github Actions due to excessively long filenames, see here.
error: unable to create file Application/8_uarts_server/RT-Thread/uart_server_rtt/rt-threa...
I want to avoid having to do extreme Github Actions hacking by editing the registry, putting the Github Actions Windows machine to sleep, waking it up, and resuming work like in https://github.com/appveyor/ci/issues/3129#issuecomment-540777559. I don't think these folders ("Application") are needed in TinyUSB at all?
I've managed to get CI running again by actually only needing to activate long paths in git in https://github.com/maxgerhardt/platform-raspberrypi/commit/8e7f3fcf79b69e5e24022fdb342e206d1d7cbc46.
- name: Enable Long Paths
run: |
if [ "$RUNNER_OS" == "Windows" ]; then
git config --system core.longpaths true
fi
shell: bash
Still, if it can be avoided, I'd love that users need to not do these modifcations.
Latest testing with completely unchanged firmware was seemingly successful. I changed the debugger!
I can even start up the device in 96 kHz mode

But it fails during use, at dcd_dwc2.c:658, which seems to be expected.
if(dir == TUSB_DIR_OUT)
{
// Calculate req...
Does not seem to be quite reliable yet, it does run into the same TU_BREAKPOINT() sometimes.
closed due to lack of activities, also the main branch moving too far now. Feel free to open an new PR if needed
@perigoso I am so sorry for the massive delay, Unfortunately, this matter slipped off my radar and the notification got lost amidst others. I admit that my lack of familiarity with Renesas MCUs make me not able to follow up on this matter more closely.
I am gonna try to sync this with master, review and pull out my boards to test, hopefully we could merge this soon as it should be.
Sorry again
Hi @hathach , unfortunately I no longer have access to the renesas development boards (job change), but I'm happy to see this being picked up
hopefully it's not too much work, the more conflicting change might be the RTOS changes
do you still remember why this disable_interrupt()/enable_interrupt() is dropped ? Or is it not needed in the first place ?
Hi @hathach , unfortunately I no longer have access to the renesas development boards (job change), but I'm happy to see this being picked up
hopefully it's not too much work, the more conflicting change might be the RTOS changes
Thank you, RTOS change is minor comparing to the whole PR. It is totally my fault, I am trying to fix/merge this as soon as I could :)
Add support for the updated fsdev peripheral in STM32G0 MCUs.
Compared with older fsdev revisions, the STM32G0 variant renamed a lot of registers & fields, some registers were extended from 16 to 32 bits and the USB memory addressing scheme was changed:
Th...
Thanks for your work ! I was thinking work on G0 after my vacation :)
this PR is not needed, since fsdev now reserve max packet for ISO transfer
this PR is not needed, since fsdev now reserve max packet for ISO transfer
I don’t see why it is a bug with tinyusb. Since you are working with rp2040, you shouldn’t clone other mcu dirver
Can you not consider cloning only a subtree of the CH32V307 HAL that excludes the application which is bursting through the max Windows path length?
I would love to include a minimal mcu driver that is used by others and well maintained if you could suggest one.
I do host https://github.com/Community-PIO-CH32V/framework-wch-noneos-sdk which I always try to keep up-to-date. It contains the HAL for all CH32VXXX chips. No application code.
Thanks, let me check this out later. Maybe I should just get rid of submodules by implementing #1464
I had fixed usbd_edpt_close() because it was needed to implement switching between alternate interfaces. Is this now possible without this fix?
I had fixed
usbd_edpt_close()because it was needed to implement switching between alternate interfaces. Is this now possible without this fix?
Yes, you can try UAC headset example.
Linux
RP2040
latest master, as of today
I'm bringing CircuitPython's use of tinyusb up to date. We were about a year behind. I'm getting a compile error here because the macro remove_volatile_cast() is not defined here:
https://github.com/hathach/tinyusb/blob/990fb6ae5c4d9d4b77c5a9ecb3a2abe899dd2712/src/portable/raspberrypi/rp2040/dcd_rp2040.c#L300
It is defined in `pico-sdk/src/rp2_common/hardware_sync/include/hardw...
Linux
RP2040
latest master, as of today
I'm bringing CircuitPython's use of tinyusb up to date. We were about a year behind. Compile error because CFG_TUSB_RHPORT1_MODE is not defined. This used to work, but I think that #1350 may have changed things.
https://github.com/hathach/tinyusb/blob/990fb6ae5c4d9d4b77c5a9ecb3a2abe899dd2712/src/portable/st/synopsys/dcd_synopsys.c#L528
The statement above is not guarded with `#...
@dhalbert you need to switch to the new dwc2 for stm32 since the one in st/synopsys will be removed shortly in the future. Maybe that would fix the compiled issue.
have you tried to bump up pico-sdk ? this cast is added recently by rpi team, and actually pass tinyusb ci.
For incoming ISO OUT packets it was possible to start DMA from endpoint to RAM before transfer was started resulting in unrelated memory corruption.
This is scenario that causes memory corruption:
Yes, I am running with pico-sdk 1.5.0. remove_volatile_cast() is there, it's just that the .h file that defines it is not being included directly or indirectly by dcd_rp2040.c.
you need to switch to the new dwc2 for stm32
Aha, I will try that.
I am thinking that #include hardware/sync.h should explicitly be in dcd_rp2040.c.
yes it probably should;
I assume this is failing because you aren't using OSAL_PICO
I assume this is failing because you aren't using OSAL_PICO
That's true. Maybe we should look at using osal across our multiple ports.
Describe the PR
fix #1464 remove all submodules in hw/mcu, these repo is now managed by an python script at tools/get_deps.py which take 'submodule' path as inputs. The existing way to get dependency with make target make BOARD={} get-deps still works by invoking get_deps.py script.
This is due to the wide range support of MCUs and the mcu sdk is often large enough. git submodule init --recursive which is convenient for most user project had a hard time with tinyusb.
https://github.com/hathach/tinyusb/blob/990fb6ae5c4d9d4b77c5a9ecb3a2abe899dd2712/src/portable/raspberrypi/rp2040/dcd_rp2040.c#L300
dcd_rp2040.c uses remove_volatile_cast(), which is defined in the pico-sdk in hardware/sync.h. But dcd_rp2040.c does not #include hardware/sync.h. When not using the pico-sdk build environment and OSAL_PICO, remove_volatile_cast() will not be defined. This PR adds an explicit #include to fix that.
Windows 11
STM32F401 custom design
Same as https://github.com/hathach/tinyusb/issues/1935
(CubeMX Makefile project on FREERTOS, using the new dcd_dwc2 driver)
In general, I can connect the USB device and I can play music or loop it back to the microphone without issues. The looped back signal looks like the one I transmitted.
Now, there are two cases:
Seems stable during operation now, but I am hitting a new issue. See
superb! thank you for yet another race condition with nrf. I guess this never ends :)
all submodules are removed now and replaced by an python script to manage dependency repos https://github.com/hathach/tinyusb/pull/1947
Describe the PR
update get-deps to make it easier to read
thank you for your PR, unfortunately, I don't see added value for combine cdc with uac2 in an example. We can't have every example for each driver combination. User with cdc interest could test out other example
Did you measure the code size difference? I believe RAM difference is only 8bytes. On RPI, it is so small to ignore.
hihi, thank you @howard0su for the PR, and sorry for late response. Recently, we have added a new API for ISO transfer, that would reserve the largest packet size before SET_INTERFACE (activation). This will help to solve the changing endpoint size of ISO transfer.
https://github.com/hathach/tinyusb/blob/master/src/device/dcd.h#L172-L175
The API is currently only implemented with stm32 fsdev, but will be added for rp2040 later as well when I have time. I appreciate your effort but I t...
everything look great, though I don't understand where is TU_IRQn is used, I couldn't find where it got used to setup USB interrupt, maybe I miss something.
@perigoso I have made some minor commits and I think we are really close to merge this. I only have an question regarding the IRQn number used by RA chip as mentioned above. That is ok if you don't remember that, we can merge it as it is for now and worry about that later on.
Another thing is the name of USB IP, I did a quick search on renesas page. As far as I can tell, Link is not the name of the controller, it seems to be used in place for connectivity, there is also sata, pcie link. If...
thank you for your PR, I just did a quick search to find a G0 board to test with. Though look like all the G0 nucleo does not come with USB connector for user. Can we use an usb breakout to D+/D- to those board to test with. Or do we need to add additional passive (RC) to it. An nucleo BSP is definitely helping, it will make it easier for other maintainers to test with and also add it into ci run as well.
At the moment, only STM32G0B1 and STM32G0C1 devices have USB peripherals.
The only affordable development board (STM32G0C1VE-EV is too expensive for me) seems to be the NUCLEO-G0B1RE.
And I'm not sure whether the nucleo has a "User USB" connector or not.
The image on the ST web page says no, but looking closely on the chip package, the pictured board has the wrong (STM32G071) MCU, so maybe that image just shows some random n...
dwc2 builds and works, so I'll close this as unneeded since st/synopsys is going away.
I feel you, I don't buy expensive kit myself as well. I have ordered an G0B1 nucleo (waiting for delivery), but look like it only has 1 usb for stlink. I checked that D+/D- is routed out to header, I have a few Adafruit usb breakout cable so hopefully it will work https://www.adafruit.com/product/4448

FIFO based R/W functions dcd_read_packet_memory_ff() and dcd_write_packet_memory_ff() need to be modified for 32bit alignment.

Both linear & wrapped parts of the circular fifo need to be read/write from/to the packet buffer.
In 16bit case linear part can only be odd or even so it's easy to handle.
Now linear part can remain 0-3 bytes after last 32bit aligned transfer...
glad that works out for you, let me know if stm32 port has any issues with the new driver
perfect ! Thank you for your PR and patient, there is nothing I could add. I only did a rebase to fix ci and will merge shortly after ci passed.
On iMX RT TinyUSB didn't work with the USB buffers behind dcache. (This happens if the RAM region is marked shareable in the MPU.)
This adds a cache flush on reset so that the reset of the shared data structures is seen by the peripheral. Otherwise, it gets confused.
perfect, thank you. Note: doc build has some issues, I don't know why, but we could ignore it for now.
Originally posted by smunaut May 21, 2022
So for a given application, I'd like to defer the decisions of OK/Error and not provide them directly as returns to the callbacks.
That is, once I get the SETUP stage, I can't immediately decide if it should stall or start a transfer. And for OUT transactions, when I get the DATA in the xfer completion callback, I can't immediately decide if the status stage should be ...
see these lines
These mcus have a dynamic linking between peripheral interrupts and the vector table, their IDE generates these files, this is derived from the generated files so there is no proper define "linking" them together
This has moved to the link_rx.h file, as it is specific to the RX family
Another thing is the name of USB IP, I did a quick search on renesas page. As far as I can tell, Link is not the name of the controller, it seems to be used in place for connectivity, there is also sata, pcie link. If you don't mind I would suggest to rename the usbip back to simply renesas ? ofc, I will do that myself.
I don't remember where I got the IP name, but I can't seem to find anything, renaming things back is fine by me
Another thing is the name of USB IP, I did a quick search on renesas page. As far as I can tell, Link is not the name of the controller, it seems to be used in place for connectivity, there is also sata, pcie link. If you don't mind I would suggest to rename the usbip back to simply renesas ? ofc, I will do that myself.
I don't remember where I got the IP name, I might have misread something, renaming things back is fine by me
It's also useful for UAC class.
For example volume changes need I2C control of external codec, which cannot be finished within 1ms/125us frame time. During this time audio data will be dropped.
Describe the PR
PICO_SHARED_IRQ_HANDLER_HIGHEST_ORDER_PRIORITY is not defined in old sdk e.g arduino mbed core.
Describe the PR
fix HAL_Delay no effect bug on st platform
Additional context
duo overwrite SysTick_Handler, so when my hardware driver call HAL_Delay function ,it's can work!!!. add HAL_IncTick in SysTick_Handler
oh, I see thank you, it is a dynamic IRQ binding. I may try to change it to CFG_TUD_*
I don't remember where I got the IP name, I might have misread something, renaming things back is fine by me
Thanks, I will do the rename, maybe calling it rusb2, most of renesas mcu use this IP I think.
Superb! Thank you @perigoso very much for generalizing the renesas driver and sorry for the huge delay. I was too busy last time (around last Lunar New Year), and lots of stuffs happening making this fall off my radar. Though that is still hugely my bad.
I made some changes but should not cause any issue since I tested with both RA and RX boards
Describe the PR
Supercedes and close #1786
Look good, thank you for your PR
Describe the PR
Note: changes looks massive but mostly whitespace.
@hathach No worries, thank you for picking this up, very happy to see this merged :)
you might want to rename the LINK_REG macro too, on the implementation files, since that was based on the Link name for the core, and now may cause confusion for readers without context
I will take this opportunity to point you at another one of my PR that you might have also missed, if you have a little time to help with that #892
Closing as this would need a big clean up I won't be doing any time soon, the project is also not planning to switch so for the maintenance might not be worth it
thank you very much for the PR, regarding the HSE_VALUE which is 12Mhz on some boards. I have updated the mm32sdk to add ifndef around the defined of SYSCLK_FREQ_XXMHz/SYSCLK_HSI_XXMHz and also add 1-DHSE_VALUE=` to board.mk that matches its hardware. This should solve this issue https://github.com/hathach/tinyusb/pull/1882/files#diff-d115a2b59f4f8d51aef8da0070cea68b35df06cb687b844eba59de2f7db7baa9R2
To be honest, mm32 isn't doing its work to maintain the driver. Requiring chaning the syst...
Thank you, sorry for super delay. will test this out as soon as I could. I need to find my own SAM3U board, I think it is delivered already.
Superb! thank you very much for the PR, since then I have made some changes to also fix IAR build for some stm32 but haven't try to compile with rp2040. The changes look great, I have synced with master and updated, will merge when ci passed.
thank you for your PR, I spotted a couple of issue. Though I have pulled and make more changes, so no worries
the mcu on this board should be K32L2A41A though
typo, must be CFG_TUH_ENABLED
@perigoso thank you very much, I have already rename everything from LINK_REG to RUSB2_REG, let me know if you spot any leftover. I have another ra6m1 board, but running out of time. Will come back to this port later on.
PS: will also review the other SAM3 pr as soon as I could.
actually this code
is wrong (and likely won't actually compile on IAR)
It should read
#define usb_hw_set ((usb_hw_t *) hw_set_alias_untyped(usb_hw))
#define usb_hw_clear ((usb_hw_t *) hw_clear_alias_untyped(usb_hw))
(Note the hw_xxx_alias_untyped vs hw_xxx_alias)
Describe the PR
maintaning work to move more board into its family
@kilograham ah thanks, I haven't tried IAR with rp2040, will make PR per your suggestion. I saw rpi team is also doing IAR support within pico-sdk as well, nice timing.
Describe the PR
It should read
#define usb_hw_set ((usb_hw_t *) hw_set_alias_untyped(usb_hw))
#define usb_hw_clear ((usb_hw_t *) hw_clear_alias_untyped(usb_hw))
(Note the hw_xxx_alias_untyped vs hw_xxx_alias)
_Originally posted by @kilograham in https://github.com/hathach/tinyusb/issues/1639#issuecomment-1474874082_
indeed - that is no coincidence ;-) and yeah the change to this PR is a result of me making changes to what was merged there ;-)
Describe the PR
Add tuh_set_interface()
Describe the PR
Which cause error in get_buf_offset() of lpc_ip3511.
we can put the CFG_TUSB_MEM_ALIGN to the struct feedback, which will make the value as 1st member to be aligned correctly ?
Yes that will work. I was thinking to avoid aligment on struct member so I moved value outside, but it should be ok.
Describe the PR
3*max_device (previously must be 4*dev and yet couldn't support 1 device with 5 interfaces while other ...@hathach Any progress on this? Having an address that needs to be different on every board be const seems like a bad plan...
If there is currently no plans to move the TODO to TODONE, is there any chance the const can be removed?
I haven't got time to reviewt net driver, please submit PR if you have suggestion.
Describe the PR
Fix #1658 bit field ordering normally start from 0 for first field


Tracing my original code (https://github.com/rabbitholecomputing/QuokkADB-firmware) the issue is _ctrl_xfer.stage == CONTROL_STAGE_IDLE);
fails because _ctrl_xfer.stage is equal to CONTROL_STAGE_ACK.
There is only 1 control transfer is active at a time, if it failed, try again later. You can implement your own fifo to queue up the pending control transfer.
@HiFiPhile the callback is already existed, did you mean you want to implement it.
Yeah, I am planning to add and board_get_uid()/board_get_usb_serial() similar to this implementation of tinyuf2 here, but always got too busy with other works.
https://github.com/adafruit/tinyuf2/blob/4fb0d86fe82659d599b034864f8b1aee1656de75/src/usb_descri...
hardware already in the loop with rp2040 pico and stm32l4 board running with self-hosted ci. Due to limited of hardware power, we cannot test every mcu. This issue is therefore is closed as complete
Per https://github.com/hathach/tinyusb/issues/718, MAC addresses are intended to be device unique, and thus should NOT be defined as consts.
I'm not sure what the longer term fix in the TODO should be, but this is a simple fix.
all
all
similar to #1855 but in much broader view. There is several analytic software that is free for opensource project. That does perform code checking againt popular standard e.g MISRA, CERT etc ... we should run as much as we could with CI to make tinyusb safer.
Doable
Describe the PR
Rename PIO_USB pin configure and value to match adafruit feather usb host. These should be part of board configure in pico-sdk later on
Describe the PR
slightly update doc and generate dependencies.rst file
Others
N/A
N/A
epin_buf and epout_buf should have CFG_TUSB_MEM_ALIGN in hidh_interface_t (HOST)
https://github.com/hathach/tinyusb/blob/master/src/class/hid/hid_host.c#L57
similar to what is in (DEVICE)
https://github.com/hathach/tinyusb/blob/master/src/class/hid/hid_device.c#L53
it's a "bug" in the code (of course the code not working buffer in driver is required to be aligned...
which board, mcu and examples you are using ? those info is mandatory
it's a CH582M from WCH (https://aliexpress.com/item/1005004587076215.html) which is not supported here but I did "dirty" host implementation (I will share the code when I finish implementation)
It requires RX buffer to be aligned so either
hid host structure should looks like
typedef struct
{
uint8_t itf_num;
uint8_t ep_in;
uint8_t ep_out;
uint8_t itf_protocol; // None, Keyboard, Mouse
uint8_t protocol_mode; // Boot (0) or Report protocol (1)
uint8_t ...
maybe it should be feature .... not bug
thanks for the info, device and host may have different requirement, some mcu requires memory for device to be aligned of 64 bytes, but have no such requirement for host. Let me check, but at least 4-byte aligned sound right.
more info ... in my implementation of bool hcd_edpt_xfer(uint8_t rhport, uint8_t dev_addr, uint8_t ep_addr, uint8_t * buffer, uint16_t buflen)
I had
R16_U2H_RX_DMA = (uint16_t)(uint32_t)buffer;
StartTransact(...);
where R16_U2H_RX_DMA is register where you write the pointer to buffer for transfer
since hidh_xfer_cb in hid_host.c is using tuh_hid_report_received_cb(dev_addr, instance, hid_itf->epin_buf, (uint16_t) xferred_bytes) to call this implementation it wou...
Describe the PR
When working with TinyUSB, my IDE (VSCode) sorted the #includes for tusb_private.h as part of automated code formatting which revealed an implicit dependency on tusb.h via build breaks when tusb_private.h is #included without/before tusb.h.
This PR simply adds the implicit dependency as an explicit dependency, fixing the build break if the #include statements are ordered differently (for example in tusb.c).
Additional context
VSCode auto-formatting changed tusb...
tusb_private.h is not meant to be included by application. Also include order is also relevant. even if it is public header, fixing code format by changing the code is not accepted.
will revise other mcu and make an PR to fix this, btw, I have ordered a few more wch boards, they seem to look good on specs. Though to be honest, I am not familliar with wch family.

Please take a look at the code change. There's an implicit dependency in tusb_private that I simply made explicit.
Having build order issues in your .h files isn't preferable @hathach. It will likely cause an issue for someone else in the future.
FYI, saw you opened a (very nice) checklist for static analysis. FYI, your cppcheck run is going to fail with this issue unfixed.
Describe the PR
fix #1976 , host and device controller may have different requirement for memory section (location) and alignment. It is better to separte these configuration. CFG_TUSB_MEM_SECTION and CFG_TUSB_MEM_ALIGN can still be used as backward compatible. However, these should be used in the future (gradually migrate device & example later)
look good, thank you. extern with variable is not prefered, we should use an callback or something in the future.
Describe the PR
fix cdc host enumeration issue when device does not support line request e.g atmega 32u4 bootloader
thank you, now it's working fine
shouldn't osal_task_delay in
https://github.com/hathach/tinyusb/blob/master/src/osal/osal_none.h#L40
be static?
I have
TU_ATTR_ALWAYS_INLINE static inline void osal_task_delay(uint32_t msec)
{
mDelaymS((u_int16_t)msec);
}
in tusb_os_custom.h
and it was working with 0.15.0 but with commit it doesn't compile (obviously: *static declaration of 'osal_task_delay' follows non-s...
device stack
rp2040 pico-w
I have an odd-ball usb-host msc application using this SD-card to usb cable: https://www.spypoint.com/en/products/cell-link-cable/cl-cbl . I'm plugging the usb end into a pico-w and the SD card end into a camera. When the camera is off or idle you can access the SD card memory via the usb as a regular usb mass storage device from the pico. But when the camera becomes a...
unmount requires a physical bus signal (SE0), if there is no bus signal change -> no event. Anyway to do it differently is only asking for troubles. If your media is not available, detect and response correctly with scsi command e.g ejected media.
This issue does not seem to be fixed. I am using earlephilhower's arduino-pico framework and updated it's pico-sdk to use the latest state of tinyusb. The issue still exists.
Submodule path 'pico-sdk/lib/tinyusb/hw/mcu/st/stm32u5xx_hal_driver': checked out '2e1d4cdb386e33391cb261dfff4fefa92e4aa35a'
Submodule path 'pico-sdk/lib/tinyusb/hw/mcu/st/stm32wbxx_hal_driver': checked out '2c5f06638be516c1b772f768456ba637f077bac8'
Submodule path 'pico-sdk/lib/tinyusb/hw/mcu/ti': checked out '14...
Windows 10
RP2040 (TinyRP2040 and Pico)
I have this issue with pico-sdk and circuitpython (after 7.3.3).
CDC is not working on windows (multiple machines). The com port is visible and I can connect to it, but no data seems to be transferred.
A simple cdc program is enough to reproduce this.
_No re...
I've tried so set #define TUD_OPT_RP2040_USB_DEVICE_UFRAME_FIX (0) in pico-sdk/src/rp2_common/pico_stdio_usb/include/tusb_config.h.
Also I tried:
target_compile_definitions(${PROJECT_NAME} PRIVATE
TUD_OPT_RP2040_USB_DEVICE_UFRAME_FIX=0
)
in the CMakeLists.txt
Same issue.
Linux
Custom RP2040 Board
https://github.com/Black-FX/RP2040_Mouse
I have developed a firmware for RP2040 to be used as a USB to quadrature mouse adaptor. I have the code there to handle mouse scroll events but none ever appear.
Class driver extension
N/A
I'm trying to move an existing codebase from the ST USB middleware to tinyUSB and running into trouble fully supporting the video (UVC) interface. In particular, it appears to me that tinyUSB does not support defining extension units and perhaps processing units in general. I'm trying to modify tinyusb to support my usecase, but I'm having trouble understanding the dif...
Linux
ESP32S3
IDF-5.0 and tinyUSB
When I create a composite HID device with ESP32S3, I encounter a problem where the PC cannot connect to the device, regardless of whether the configuration descriptor exceeds 64 bytes or not. The composite device consists of a Generic Input Output Device, a Keyboard Device, and a Mouse Device.
composite generic input/output and keyboard desc:
const uint8_ t mine_ ...
Mouse wheel data is not on boot protocol mode with tush uses by default (for simplicity). You need to set it to report protocol mode then parse the HID descriptor etc.
There's a function called tuh_hid_set_protocol to do this.
/*HID Class Descriptor*/ 0x09,//1. Descriptor length
Is that length right?
I think it's a good idea to add a set of generic callback functions, similar to the audio class. The functions shown below.
https://github.com/hathach/tinyusb/blob/5add4c97fa834004e6a3b267345a13c6d3c9514a/src/class/audio/audio_device.c#L1882
https://github.com/hathach/tinyusb/blob/5add4c97fa834004e6a3b267345a13c6d3c9514a/src/class/audio/audio_device.c#L1981
When I initially implemented the video class, I thought so.
If frequently used properties comes up, it would be better to replace the...
Ok, I found this (still have to test that)
https://forums.raspberrypi.com/viewtopic.php?t=335296
But what I'm interested in is why tiny_usb worked without using DTR in earlier versions?
Describe the PR
Add handling bulk endpoints in streaming interface. This feature is only compatible with streaming, and the still image capture function is not yet implemented.
Using bulk endpoints may allow for more bandwidth utilization than isochronous endpoints. It may also enable higher image sizes and frame rates.
Additional context
I have tested this PR on Raspberry Pi Pico and Windows 11.
I have confirmed that the video_capture can display color bars up to 128x96 60...
@Staacks
If you have time, could you try this PR for the your project.
Using bulk endpoints may allow achieving 160x144@30fps.
Wow, thanks, that would be fantastic. I will try it soon! I am currently a bit caught up in another project and my day job, so I cannot promise that I get to it before Easter, but my fingers are definitely itching to test it.
CUSTOM since NONE use hcd_frame_number to implement osal_task_delay but board/chip SDK has already mDelaymS
tusb_config.h
/*
* The MIT License (MIT)
*
* Copyright (c) 2019 Ha Thach (tinyusb.org)
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merg...
hack and dirty implementation
in fact this is only 3 files: tusb_config.h, tusb_os_custom.h, and hcd.c (since I only need host for now) (I didn't use IRQ(for transfer, I use it to detect connection) since example in SDK didn't and I cannot make it work with interrupts)
Forgret about it ...
I include osal_none.h (to not implement other OS function by myself ...) and OS_NONE has own implementation ... silly me
Host, osal_task_delay
Any
I'm using non supported here MCU/Board and I wan use OS_NONE but provide custom osal_task_delay
in osal_none.h
#if CFG_TUH_ENABLED
// currently only needed/available in host mode
#ifdef SOME_CONFIG_FLAG
#include "tusb_os_none.h" //provided by platform implemetation of osal_task_delay
#else
void osal_task_delay(uint32...
I see some bsp/sdk provide an better delay than using hcd frame number, which only exist if there is an device attached to bus. I think we can have an optinal callback to get timestamp instead of having an custom OS. There is other place that need this callback as well. Let me think which name we should use
look great, though I am on the run for other things, will review and test this as soon as I could
Please forgive my ignorance for not giving this debug message in the first time.
This is a debug message about "compound IO and keyboard device", failed:
USBD Bus Reset : Full Speed
USBD Setup Received 80 06 00 01 00 00 40 00
Get Descriptor Device
Queue EP 80 with 18 bytes ...
USBD Xfer Complete on EP 80 with 18 bytes
Queue EP 00 with 0 bytes ...
USBD Xfer Complete on EP 00 with 0 bytes
USBD Bus Reset : Full Speed
USBD Setup Received 00 05 18 00 00 00 00 00
S...
what is your tinyusb log with CFG_TUSB_DEBUG = 2
After you prompted me to enable DEBUG, I used it to find a fatal error, one of the Settings was not set correctly, which caused me the above problem. I am very sorry that I did not check in place, and I am very sorry for the trouble caused to everyone. Now allow me to close the question.
An alternative to parsing the HID report descriptor is to ask the caller to pass the information that would be retrieved from the parsing. We do this in CircuitPython, passing in the report IDs and the report lengths: https://docs.circuitpython.org/en/latest/shared-bindings/usb_hid/index.html#usb_hid.Device.
An HID report descriptor parser is useful for other things too, especially host support, so this may not be the best choice in the long run. But it saved writing a parser, especially b...
Use usbd_edpt_claim, usbd_edpt_release in vendor device class
An issue similar to https://github.com/hathach/tinyusb/issues/1470 was discovered in my testing on a PCA10059 running MyNewt/Nimble. This PR ports over the use of the endpoint claim and release mechanisms used in the cdc class, which seems similar. This resolved the race condition I encountered that would result in IN transfers getting stuck until the next OUT transfer was started.
device stack, hid
all
without parser, device hid driver does not know if report id is part of the report or not and sometime may present data especially output report incorrectly ID = invalid + whole report. This may confuse application if not aware of the issue.
simple parser enough to detect report ID present.
@dhalbert
Host Driver (HCD)
all
currently only standard ACM device is supported. vendor usb uart bridge chip aren't tested yet (probably using vendor specific driver).
Add host driver for those since they are popular enough on older design.
@ladyada
yes! can start with CH9102 maybe its the easiest?
Describe the PR
This draft pull request shows a possible way to implement FreeRTOS support for RP2040.
To use FreeRTOS with RP2040, you must install the FreeRTOS-Kernel source in a way that family.cmake can find it. Easiest place to put it is
${PICO_SDK_PATH}/../FreeRTOS-Kernel
Make sure to use the smp branch. That is:
cd ${PICO_SDK_PATH}/../FreeRTOS-Kernel
git checkout smp
In your project's CMakeFiles.txt, use libraries
tinyusb_board_freer...
Describe the PR
This is a very early driver for the fs/otg usb IP found in wch chips (device mode only)
Tested on CH32V307 and partially on CH32V303.
That IP may be present in other WCH chips such as CH32V2xx etc...
This PR is a request for comment mostly (see below)
Additional context
The driver is derived from the HS one but targets the FS/OTG usb controller, with the same restrictions (resume/stall not supported, no cleanup...).
These IPs are similar but not compatible. I'...
Sample updated that I missed earlier. It should pass the gated build now.
UVC
rp2040
UVC example misses VC_PROCESSING_UNIT which is needed for controlling things like brightness.
I want to get callback when user changes brightness from webcam program.
@tobozo this is great, but if abs_mouse is to be a first-class citizen in TinyUSB, shouldn't we add a couple helper functions to hid_device.h to match the base mouse?
Like:
bool tud_hid_n_abs_mouse_report(uint8_t instance, uint8_t report_id, uint8_t buttons, int16_t x, int16_t y, int8_t vertical, int8_t horizontal);`
static inline bool tud_hid_abs_mouse_report(uint8_t report_id, uint8_t buttons, int16_t x, int16_t y, int8_t vertical, int8_t horizontal)
{
return tud_hid_n_ab...
@earlephilhower thanks for the suggestion :+1: should I also add the C function in hid_device.c ?
bool tud_hid_n_abs_mouse_report(uint8_t instance, uint8_t report_id, uint8_t buttons, int16_t x, int16_t y, int8_t vertical, int8_t horizontal)
{
hid_abs_mouse_report_t report =
{
.buttons = buttons,
.x = x,
.y = y,
.wheel = vertical,
.pan = horizontal
};
return tud_hid_n_report(instance, report_id, &report, sizeof(report));
}
Yes, that would be needed since we only have the prototype otherwise which will make the linker unhappy. :)
Awesome, thanks! Makes it as simple to use as the USB mouse APIs!
ideally the touch zone should have a shape proportional to the target screen so it's not exactly as intuitive as using the relative mouse, especially when the desktop has multiple screens :sweat:
there are a lot of use cases anyway, I remember exploring those with an ESP32-S2:
Trailing whitespace removed that cause the pre-commit to fail. The rest passed.
Thanks for your PR, tested ok on my LPC55S66 custom board.
If possible it would be nice to know what report IDs exist too, looking to see if a report descriptor supports a specific feature request or not
Linux
Raspberry Pi Pico
/examples/host/cdc_msc_hid
When connecting a USB keyboard (or mouse) to the Pico via a USB hub, the process fails when trying to setup the keyboard (or mouse) throwing a Data Seq Error.
@maxgerhardt I started to use PIO for some sketch recently, it is indeed a pain to wait for all submodules clone. I am glad we finally remove them in tinyusb project.
The USB3300 reset pin for Waveshare openh743i board was never initialized, so resetting the chip doesn't work correctly. This PR initialize the pin as OUTPUT before any use.
will revise other mcu and make an PR to fix this, btw, I have ordered a few more wch boards, they seem to look good on specs. Though to be honest, I am not familliar with wch family.
BTW, I've also ordered WCH-Link and 203 board ... And have a problem to make it even blink beacause in fact LEDs(2 and 3 as 1 is just power) ARE NOT CONNECTED TO ANY PIN ... you need to connect LED pins to some pins (fx I've connected it to PA0 here)
. Only additional setup required is APB clock to USB, CRS setup and enabling VDDUSB via PWR->CR2.
USB_PMAADDR is not defined in stm cmsis headers but rather USB_PMAADDR_S and USB_PMAADDR_NS (secure and non-secure modes respectively). The definition here is relative to USB_BASE which defaults to USB_BASE_NS but the curren...
hcd, dcd
all
The MAX3421E USB peripheral/host controller via SPI transportation, commonly used in Arduino Host Shield. Haven't looked at the chip datasheet, but if we could support this chip it would make it possible to run TinyUSB host on most of mcu on Arduino platform
TBD
@ladyada
which board you are testing with, would you mind adding an bsp as well if possible ?
MacOS
Raspberry Pi Pico
I was trying to follow along rumbledethumps picocomputer project using MacOS as host and ran into a problem with sending serial break from Mac host to the Raspberry Py pico running an image containing tinyUSB and picoprobe. I have confirmed that break works fine from a Linux host (and I have been told it also works on Windows...
Because FreeRTOS_Kernel_import.cmake has a fatal error message lines 47-49.
if (NOT FREERTOS_KERNEL_PATH)
message(FATAL_ERROR "FreeRTOS location was not specified. Please set FREERTOS_KERNEL_PATH.")
endif()
As I understand it, we do not want pico-sdk to fail to build if FreeRTOS-Kernel is not installed.
thank for the tips, the board isn't deliveried to me just yet. It normally take 2-3 weeks to ship across border to my desk.
do you have other USB hub to test with, just to make sure it is not as generic issue ? I tested previously fine with my hub.
usbd will only parser infomation that it needs, others that involed application code should be done by application.
look good, thank you. There is quite of duplication code for driver with stream/buffered endpoint. I have added tu_edpt_stream (read/write) API. In the future we will migrate to those instead
https://github.com/hathach/tinyusb/blob/master/src/common/tusb_private.h#L124
currently only cdc host used this stream edpt https://github.com/hathach/tinyusb/blob/master/src/class/cdc/cdc_host.c#L61
Yeah makes sense, i ended up writing my own simple parser for grabbing what i needed in the end.
I have tested on a custom PCB and a generic HID in/out test works as expected. Unfortunately I do not have a development board (Nucleo/Disco etc) to test on.
The STML412Nucleo bsp seems to be the most similar with only the GPIO assignments for LEDs/button/UART differing. I can edit this and attach if requested however it would be untested.
thank you for your PR. Look good, I could add an bsp for devboard later on.
I have tested on a custom PCB and a generic HID in/out test works as expected. Unfortunately I do not have a development board (Nucleo/Disco etc) to test on.
The STML412Nucleo bsp seems to be the most similar with only the GPIO assignments for LEDs/button/UART differing. I can edit this and attach if requested however it would be untested.
That is OK, I thought you are using one of ST devboard, adding bsp actually allow the ci to run that could potentially rule out some mistake. B...
superb !! thank you, give me a bit of time, I will try to review this as soon as I could.
Thanks for quick response!
you double checked that macOS indeed send out BREAK signal ?
Yes, by way of a USB to Serial adapter board connected to the UART pins on the pico. This board passes the break from both MacOS and Linux minicom.
please test again with cdc_msc example, you will need to add the break callback to main.c. Since that is what I am always testing with.
**I have now modified hello.c, adding a callback and printing a BREAK message when detecting a...
@hathach The build pre-comit is failing. I do not understand why file FreeRTOS_Kernel_import.cmake requires a blank line at the end of the file. The file pico_sdk_import.cmake does not have one.
@hathach The build pre-comit is failing. I do not understand why file
FreeRTOS_Kernel_import.cmakerequires a blank line at the end of the file. The filepico_sdk_import.cmakedoes not have one.
You need to leave an empty line at the end of the file to make ci check happy. On my editor the pico_sdk_import.cmake does have one.

Yes, by way of a USB to Serial adapter board connected to the UART pins on the pico. This board passes the break from both MacOS and Linux minicom.
Which Serial Adapter, FTDI/CP2104 using different driver than ACM, you need to double check to see if BREAK is indeed sent over ttyACM (not ttyUSB with other device).
I have now modified hello.c, adding a callback and printing a BREAK message when detecting a break. Running the cdc_msc example produces the same result as my previous tes...
I am making some chagnes to the cmake as well to better support both esp32 and rp2040 as well as others later on. https://github.com/hathach/tinyusb/tree/cmake . I am currently busy, but once I get that merged first, I will hep to sync up this branch
Describe the PR
Linux
NA
CDC-NCM /src/class/net/ncm_device.c
static void handle_incoming_datagram(uint32_t len)
{
uint32_t size = len;
if (len == 0) {
return;
}
TU_ASSERT(size >= sizeof(nth16_t), );
const nth16_t *hdr = (const nth16_t *)receive_ntb;
TU_ASSERT(hdr->dwSignature == NTH...
Unfortunately I do not currently.
The hub does work with both a raspberry pi 4 and with my desktop; however, it does look to be based around a HS8836 which other folks online seem to have issues with in other situations.
I'll see if I can get my hands on another hub to test with.
when you are able to test with other hub and can narrow the issue to the specific chipset, please detail your hub make and model as well as link, picture etc.. If it is the case, I will try to see if I could find it locally here for testing.
Describe the PR
1042 files don't name the USB peripheral like the others in the series.
Hi @hathach - The CDC + UAC2 composite device happens to be important especially in the amateur radio community.
Modern radios ('rigs') like Icom IC-7300 + IC-705 expose a sound card and a serial device ('composite device') to the computer over a single USB cable. This allows for Audio I/O and CAT control over a single USB cable which is very convenient.
By including (and enhancing) the example in this PR, we enable the amateur radio community to build ('homebrew') radios with similar f...
@hathach I have one of the radios mentioned and understand the motivation.
@kholia I think it would be good to add a README or comment to explain the motivation, rather than have it be implicit. That would make it more findable by a search engine.
@kholia You could also make your own repo that is just the example, so that you can point to it, and write an extended README that would explain what this is for.
Windows 11
esp32 s3
default
null action
no
no
origin code:
uint8_t const tud_descriptor_configuration_cb(uint8_t index)
{
(void)index; // for multiple configurations
return (uint8_t const)EspTinyUSB::descriptor_config_if;
}
Describe the PR
fix audio comment error
No, you can't just try again later. It is stuck in ACK stage forever. All subsequent attempts fail.
Describe the PR
Even when we get an empty "status change" interrupt from a hub, schedule another interrupt poll.
During enumeration, when there are multiple devices attached to the hub as it's plugged into the Pi Pico, enumeration hangs, because we get a "status change" callback with value zero. With this patch, we retry several times on "zero" status change callbacks, until eventually we succeed.
Additional context
If applicable, add any other context about the PR and/or scre...
So I managed to get my hands on a Sabrent HB-MCRM and everything seems to be working fine with that (log of working one here).
The Sabrent one isn't mine (so I didn't tear it apart) but it seems to claim it's using a Genesys Logic controller... probably a GL850G.
The one that doesn't work is a no-name brand... looks like the controller is actually a Huasheng Electronics HS8836A which seems to be foun...
there is a on-going PR that fixes an issue with hub, would you mind trying it out https://github.com/hathach/tinyusb/pull/2016
Linux
Pico 2040, ESP32-C3 and ESP32-S3
Pico SDK 1.5.0 with default TinyUSB submodules.
Espressiv SDK 11.2.0 with default TinyUSB submodules.
Correct me if I'm doing something wrong, but here's what I'm observing when trying to use the least power on the USB device by not doing uneccessary operations, such as spamming a HID report when not needed:
I have a gamepad device report mechanism based on the TinyUSB examples.
...
This fixes https://github.com/hathach/tinyusb/issues/1830
Some context: https://github.com/raspberrypi/pico-feedback/issues/324
This commit makes it so that when setting the START_TRANS bit in the SIE_CTRL register, along with some other bits, we first set all the other bits, then wait some cycles, and then set the START_TRANS bit.
Doing so protects against a situation where the USB controller is reading the register at the same time and gets an incorrect value.
The assembler part...
So with LOG=3 I'm seeing usbh_edpt_xfer_with_callback 781: ASSERT FAILED rather than the Data Seq Error.
With LOG=2 or lower I'm still getting a Data Seq Error.
Not so hack and dirty implementation (finally got IRQ work form me) for CH32V20x
https://gist.github.com/SelvinPL/68637937286e4d530a0f6a58807850a3 (MIT License - you can use it)
(to compile you need to comment osal_task_delay in tinyusb source , connected to: https://github.com/hathach/tinyusb/issues/1987 - i could not find a way to get frame count)
BTW it can be ported to 58x since USB registers are the same (just start at different place)
from20x SDK
typedef struct
{
__I...
@sanjay900
https://gist.github.com/SelvinPL/99fd9af4566e759b6553e912b6a163f9
Works with most USB gamepads (nintendo switch pro not included but tested with PS4 and generic pads over USB)
Finally I've got my hands on G0 :)
I'm using a STM32G0B0RET6 soldered on NUCLEO-G071RB and a USB breakout cable.
I've added a NUCLEO-G0B1RE BSP, since B0 and B1 devices are very similar I'm compiling as STM32G0B1RET6, the only deference is B0 doesn't has HSI48 so I'm using HSE PLL clock in the BSP.
cdc_msc example tested ok, there are some remaining works:
USB_IRQHandler namingOK, I am back. I have now built the modified cdc-msc example in the tinyusb example tree:
make BOARD=raspberry_pi_pico DEBUG=1 LOG=2 all
with my modified main.c, as attached earlier.
But, alas, not much new to report. The break is detected when connected to /dev/ttyACM0, but not when using MacOS, where there is no /dev/ttyACMx, but the pico usb is seen as /dev/tty.usbserial-0001. Logging over the pico UART does not display anything, so I have nothing more to attach, I'm afraid. I ...
Thanks for your quick fix.
With #define CFG_TUSB_DEBUG 3 this breaks connecting to an USB keyboard, it is an old Apple M7803. I attached the log with ipopov's pull request code and the previous commit in his repo, hash: 28817a715024c82b78f9b9d19f37a72771870759
The error with ipopov's code comes up as Queue EP 81 with 1 bytes ... usbh_edpt_xfer_with_callback 781: ASSERT FAILED
ipopov's code works find with #define CFG_TUSB_DEBUG 0
I was hoping this pull request would fix an issue with an unbranded two ...
you know, i totally missed that too, but this will help me a bit thank you
Adds more in depth documentation of how tud_task does not need to be polled in implementations that use an RTOS / scheduler.
Describe the PR
This adds documentaiton showing how tud_task doesn't need to hold the CPU through polling when tusb_config.h is set to use an RTOS.
Additional context
If applicable, add any other context about the PR and/or screenshots here.
I can report the same issue using macOS 13.3.1: the BREAK is not received:
minicom -D /dev/tty.usbmodem14401
# press Meta+F, which shows a visual indication that claims a BREAK has been sent.
Also tried with a self-written tool that holds the BREAK signal for 1sec -- same issue.
It works just fine on Linux kernel 5.15.
@Kriechi Could you please upload log with CFG_TUSB_DEBUG=3
I'm highly doubt BREAK is not sent for ttyACM class under MacOS
@HiFiPhile I'm actually "only" running this test via CircuitPython 8.0.5 on an RP2040, though I would be even more surprised if there is some host-platform dependency in this code path: https://github.com/adafruit/circuitpython/pull/7227/files
though I would be even more surprised if there is some host-platform dependency in this code path
CDC driver of TinyUSB is compliant to ACM specification, and BREAK works on Windows and Linux. So it sounds like MacOS does something funky.
Also broken on macOS 12.6.4.
I tried with both the tty and the cu device types under macOS - same issue in both.
The attached image is from DOS and Windows. MacOS didn't display any CFG_TUSB_DEBUG=3 message when sending a break as such:
import serial
s=serial.Serial('/dev/ttyACM1')
s.sendBreak(100)

I have the same experience with Bluetooth SPP (rfcomm) on macos, basically it ignores some of cotnrol signals. That is why I suspect that macos does not send BREAK signal to acm device at all. Previously, I monitor it with macos console/log (forgot) for kernel/IO log, you may also want to try it out. Though the easiest way is hooking the usb analyzer to see if the control is actually sent via USB bus. When I have time, I will fire up my old macbook and try to capture its USB bus.
my G0 board is also arrived, I will test this out as soon as I could.
does tinyusb work on a raspberry pi 4?
Describe the PR
The Microchip XC16 compiler is just a rebranded GCC 4.5.1 with some modifications, so, it defines the __GNUC__ macro as well. However, GCC 4.5.1 is so ancient that it doesn't support the __has_attribute function. This resulted in a compilation error. Fortunately there's way to detect it via the __XC16 macro. This pull request solves the problem.
managed to fix that by symlinking aarch64-none-elf-gcc to gcc, now i'm getting
CC board.o
CC main.o
CC msc_disk.o
CC usb_descriptors.o
CC tusb.o
CC tusb_fifo.o
CC usbd.o
CC usbd_control.o
CC audio_device.o
CC cdc_device.o
CC dfu_device.o
CC dfu_rt_device.o
CC hid_device.o
CC midi_device.o
CC msc_device.o
CC ecm_rndis_device.o
CC ncm_device.o
CC usbtmc_device.o
CC video_device.o
CC vendor_device.o
LINK _build/raspberrypi_cm4/cdc_msc.elf
/usr/bin/ld: cannot find -lnosys
collect2: error: ld returned 1 exit status
make: *** [../../rules.mk:172: _build/raspberrypi_cm4/cdc_msc.elf] Error 1
Trying to use it bare metal? It did a while ago but I haven't used it recently. (CircuitPython bare metal uses it)
i'm pretty new to this. i saw your video. there is a project that emulates the portal of power for skylanders using a pico, i was hoping to port the functionality to a pi 4 with a touch screen and make it a little more kid friendly
I don't know what the skylanders thing does but you likely don't need a pi 4 to change how it works
i know i don't need a pi for it's base functionality. this is the base project: https://github.com/NicoAICP/KAOS
instead of using the lcd/buttons, i want to make a touch screen interface for it
Something like https://www.adafruit.com/product/2050 would allow you to do that with a pico
Setup : Logitech G940 ; rp2040 boards : raspberry pi pico & waveshare One ;
Adafruit teenyUSB port library on secondary USB port, teenyUSB native lib on main USB port.
120 & 240 Mhz. Code is example from lib.
First byte is always 0x01. Delay, sleep, DEBUG - no effects.
Only need - is last two bits in report[0x0000]
I'm looking to be able to click and swipe. Similar to behavior my son already knows from his tablet. I really don't think the Pico is going to have the power for everything I want to do. At least not be able to do it smoothly.
There are a couple of different character types. I want to be able to have a smooth graphical interface for displaying their categories. When he clicks on an icon for a category, I want them to be able to swipe up and down between the characters available in that category. There will also be a back button to go back to the category selection screen.
My first thought was to just use the Pico and connect to it over a serial connection to give a commands. Then I read the pi 4 can act as a USB device and that seemed like the easier path. It's starting to feel like my over engineered serial communication will be easier
you might be surprised how fast the pico is
I did look into it. I was also looking at another chip I can't remember what it was that was slightly more powerful. Still not enough to do everything I want to.
look great, thank you. Though could you update the PR to use __GNUC__ < 5 with has_attribute()
__has_attribute() is introduced since gcc version 5. we could replace XC16 with more generic __GNUC__ < 5
look good, thank you. Though can you move the note for RTOS to OSAL porting guide per review
I think we should move this explanation into above OSAL, since this is porting guide and is talking about API that needs to be ported for device.
@bjonnh Did you come up with a good solution for this issue? My solution to this problem in my projects that deal with multiple cables on input was to use raw MIDI packets (tud_midi_packet_read()) and manage the cable number in the application.
@hathach The change @mikee47 submitted is correct per the MIDI Class spec. 0x8 is Note Off. 0x9 is Note On. I pasted the table from the USB spec for your convenience.

I have a solution yes, I'm just not sure how this could be included in tinyusb.
You can find the code here for a sort of "generic driver"
https://github.com/bjonnh/dinoctopus/tree/main/lib/usbmidi
I'm using the AdaFruit library and I'm storing the cable number.
This is how I use it:
https://github.com/bjonnh/dinoctopus/blob/main/src/pico/midi/midirouter.cpp
I'm just not sure yet how to include that properly in tiny usb.
@hathach The change @mikee47 submitted is correct per the MIDI Class spec. 0x8 is Note Off. 0x9 is Note On. I pasted the table from the USB spec for your convenience.
thank you, I am actually planning to review your midi host, but couldn't manage the time. I gues we could merge this quick fix first.
I did USB-MIDI for SiLabs EFM8UB and EFM32GG, using the SiLabs USB stack, and I ported it to TI Tiva. This was before I learned of TinyUSB.
The issue, I think, is that so much of what a MIDI thing (controller, sample playback device, whatever) does is application dependent. This leaves the use of things like Cable Numbers entirely undefined at the protocol level. It is up to the application to look at the (if MIDI In) incoming packet and decide if the Cable Number, the Channel, and even th...
Does pio usb on the pico work as a pass through? Mitm kind of thing and is there any examples that do this?
I know there is an Arduino library for it. I imagine there are plain C examples too
I looked at making the two function calls in tinyusb work as the API defines them. If we keep the USB MIDI receive FIFO structure the same, the tud_midi_n_available() function requires peaking at the packets in the USB receive FIFO without pulling data and counting the number of packets that match the specified cable number. The tud_midi_n_stream_read() function would require pulling only those packets from the specified cable out of the receive FIFO, which is possible but complicated. An...
I approve this change so please merge if you are happy @hathach
Thank you very much for the PR, I have an question whether we could rewrite the asm to do nop instead since that what I would write when wanting to kill a few cycles.
is this 6 nop instruction, could we just write it as folows.
__asm volatile("nop; nop; nop; nop; nop; nop;" : : : "memory")
Also It would be nice to add comment why we need this e.g `START_TRANS "seems" to have the same behavior as AVAILABLE bit described in section 4.1.2.5.1 Concurrent access rp2040 datasheet v2.1" etc...
I don't have an opinion on this, I just followed what's already in _hw_endpoint_buffer_control_update32 in rp2040_usb.c. That was written by @kilograham I believe. I don't know if it makes any difference. If you want NOPs tell me if you want 6 or 12 of them as existing code delays for 12 cycles and a single NOP is 1 cycle (I think). This should only make a difference on massively overclocked chips as 3 cycles should be enough at 133MHz.
nop is 1 cycle, b 1f is 2 cyles so they aren't the same (and the b 1f is smaller`)
as of SDK1.3.1 there is a busy_wait_at_least_cycles(cycles) method which could be used instead (i.e. busy_wait_at_least_cycles(12)
thanks @kilograham for explanation, @jfedor2 what do you think, would you mind chaing it to busy_wait_at_least_cycles(12) as suggested.
Originally posted by Jubatian April 19, 2023
Hi,
Would like to ask about the behaviour of tud_msc_read10_cb() in a scenario which seems to not work like I was expecting.
I have a relatively slow data source (an SPI Flash chip).
The existing architecture (with a different USB library I am migrating from), when a read request arrives from USB, calls a callback to notify the Data Source module that it n...
yeah, I think you are right about this. The way the msc driver is doing is queuing its self back using the same usbd event queue. Since tud_task() trying to process all the event before return. This cause an loop() without giving back the cpu. I think we could fix this by adding custom field for tud_task() to skip it until next time or so.
PS: I made an issue based on this discussion, since it is indeed an bug. Let move discussion there, thanks.
_Originally posted by @hathach in https:/...
Wow, thank you for acting so quickly on this!
Wasn't anticipating so, glad it seems like the way I am trying to use it should be working if this can be fixed! :)
still haven't decided which is best way to do this, but I may follow the approach using by FreeRTOS-kernel https://github.com/FreeRTOS/FreeRTOS-Kernel/blob/main/CMakeLists.txt which also requires an external file config I.e adding CMakelists.txt that define tinyusb as a lib but requires an target that expose tusb_config.h in the include path. Pico-sdk can define both no os and freertos config, and one that does not speciy the freertos config in the library link will use the no os one. Let me ...
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.
Describe the PR
I have come to desicion that we will use CMake as next build system (existing make should still be supported). It is not CMake is better than meson, but cmake is used more common in embedded e.g CMSIS_5 and FreeRTOS-Kernel, it is just better for us to make use of cmake as well. Thank you for your issue.
PS: Initial CMake is added with https://github.com/hathach/tinyusb/pull/2039 (still more works to do).
look great, thank you
@hathach That works for a single, stand-alone project but I think it does not work if you build the project from the pico-examples project? The top level CMakeLists.txt contains include(pico_sdk_import.cmake) which includes tinyusb build which prevents using the proper CMake variables later.
Linux
pico
cdc_msc example with CFG_TUD_CDC_EP_BUFSIZE = 256
send 256bytes, with exact 64 bytes each. DCD won't notify tinyusb until all 256 bytes are received even there is a huge delay between each 64-byte packet.
run following script on PC
from serial import Serial
serial = Serial('COM5', baudrate=4_000_000)
serial.write(b'\x46'*64)
print(serial.readline())
Hello hathach:
Here're some optimizatoins for the HID class and a sample configuraiton.
thank you for your PR, please check out review for my questions on the changes.
please explain why adding this change
please explain what is this template used for ?
report ID count is application-specific and should not be part of configuration parameter.
I found that the macro didn't support two different Report IDs(in / out), so I tried to separate them.
For example: If I need a report id(1) for out and another one(2) for in, I won't get the data throuth this original macro.
During designing a usb generic HID communication, I found that the macro didn't support two different Report IDs(in / out), so I tried to separate them.
For example:
If I need a report id(Report ID: 1) for out reports and another one(Rreport ID: 2) for in reports, I won't get the data through this original macro.
if template descriptor does not fit your need, you don't need to use it, just make your own descritpor. These template only cover the most common usage by user. Therefore this should be reverted !
Describe the PR
mcux-sdk from 2.13.0 remove CMSIS folder, use the lib/CMSIS_5 from arm instead.
checking in on this one
Describe the PR
Add host serial driver for vendor chip, implement #1991 support
Although FTDI and CP210x are not part of CDC class, it is defined as subclass to only to re-use CDC driver API. And these serial driver work as if it is a subclass of CDC, occupies an CDC interfaces with the same API for application simplicity/convenience.
While calling tud_cdc_n_get_line_coding, the structure is copied into the destination.
Dump of assembler code for function tud_cdc_n_get_line_coding:
0x000193f4 : mov.w r2, #2112 @ 0x840
0x000193f8 : ldr r3, [pc, #20] @ (0x19410
)
0x000193fa : mla r0, r2, r0, r3
=> 0x000193fe : ldr.w r3, [r0, #6]
0x00019402 : str r3, [r1, #0]
On some platform (tested on LPC55S28), the address needs to be 4-bytes aligned. Without this, the address is
(gdb) p &_cdcd_itf.line_coding
$3 =...
Thank you, I push an update to add aligned 4 for host driver as well. Actually, this isn't issue since M4+ can access non-aligned data. However iirc lpc55 eventhough is m33 but its highspeed usb can only access 4-bytes aligned memory region which cause the issue. (fs usb probably work just fine).
Thanks a lot for extending the fix.
Indeed, used it on SAMD21/51 in the past without issue, so I was a bit confused initially about the issue.
Thank you for the quick review and approval!
thank you for your PR, I moved the note to OSAL
Windows 11
Custom board with STM32H753
Custom firmware with a combination of uac-headset and 2 cdc serial ports
The symptom is that the interrupt handler sometimes ends up in a neverending loop. This occurs because the TX-fifo-empty interrupts fires. This happens by default when the fifo is half-empty. The interrupt-handler only wants to write a full packet. If it doesn't fir, nothing happens and the interrupt fires again....
Double the size of TX fifo so that a new packet can be pushed when the fifo is half-empty
Fixes #2049
Fixes #1737
Describe the PR
Describe the PR
Due to the upcoming Arduino Portenta C33, we'd like to mainline some of the work we've been doing to support the Renesas RA6M5 HS port. The board support packages will come in a subsequent PR.
Most of the changes should be 100% backwards compatible, except the need for the user to explicitly specify CFG_TUSB_RHPORT0_MODE (if the FS port is going to be used) or CFG_TUSB_RHPORT1_MODE (for the HS port)
I didn't find any way to add this information in the board.mk ...
Superb! Thank you for your PR. I am on vacation, and will check this out afterwards (~7 days)
@hathach ping, is this by chance on your radar as something in need of improvement? There has been no further discussion since @morio wrote about this a couple of weeks ago.
will review this soon, just come back from vacation and there is quite a bit of work I have to do first.
yeah, you are right, I think I will need to add _freertos to the library in the cmakelists.txt target. Another way to solve this is don't inline osal_ function, that allows to link to osal implementation later. However, I don't feel to go that approach since it requires too much changes for existing projects that use tinyusb. _freertos suffix target then, I am also slowly adding cmake target for tinyusb. Will continue to do that and make changes as needed regarding this PR.
@dallaswood96 @hathach I am experiencing the same issue on Windows 10/11 + STM32G4. Reports sent by the host reach the device, and the device responds to the requests, tud_hid_report() returns success, but these responses (transfers Device -> Host) never reach the host. I am using libhidapi on the Host, and hid_read_timeout() always returns zero (timeout reached). I am completely stuck and have no idea how to proceed further. On Linux host everything works like a charm.
fyi, i have been crazy busy, and will be for a bit longer, so apologies for not getting to this yet.
New port support
efr32fg25
Silicon Labs released their new Flex Gecko, efr32fg25. It is the first Flex Gecko with a USB peripheral.
I would like to be able to work with the TinyUSB stack over the efr32fg25 device.
if the mcu use dwc2 controller like other gecko chip, most of the work is already done. You only need to minor mcu driver and bsp to get it running. Unfortunately I don't have any board with this mcu and have no plan to buy one, unless it is like sub 10$
iar_template.ipcf
Describe the PR
Fixing the IAR template to include missing devices, and removing legacy link to usbh_control.c
Thanks for your PR, I've fixed it locally but forgot to make a PR...
I have created an example USB MIDI device with 2 MIDI In and 6 MIDI Out here. You may find the files midi_device_multistream.h helpful for building a USB descriptor with an
arbitrary number of virtual cables. It uses the Boost Preprocessor library to help.
I have created an example USB MIDI device with 2 MIDI In and 6 MIDI Out here. The file midi_device_multistream.c contains an implementation of tud_midi_demux_stream_read() and
the example program uses it to de-multiplex the virtual cables received on the OUT endpoint and route them to the 6 DIN MIDI
Out jacks. I did not submit this as a pull request because midi_device_multistream.h has a set of helper macros for building
a USB d...
thank you @rppicomidi for the update, and the example, I think this could be closed now.
fyi, i have been crazy busy, and will be for a bit longer, so apologies for not getting to this yet.
No problems, we are all busy, I am actually working to add cmake build to tinyusb repo as well (for src/ and all other mcu families). Also latest freertos-kernel is adding support for CMake as well https://github.com/FreeRTOS/FreeRTOS-Kernel/blob/main/CMakeLists.txt
Describe the PR
Hi @HiFiPhile, I'm relatively new to TinyUSB and just got it working on the STM32F429 Evaluation board running @180MHz with the external High Speed PHY. I'm using an adaptation of the examples\device\cdc_msc configuration so it just enumerates 1 CDC port and using the simplified cdc_task() from examples\device\cdc_msc .
After using your python script for testing th...
Without compiler optimization for GCC, I get 1.90MB/s throughput on vanilla code and 2.23 MB/s with 2048 byte buffer sizes.
When enabling optimization, it roughly doubles to 4.52 MB/s with the 2048 byte buffers.
Indeed these numbers are not good for HS transfer...
I thank it's from both hardware & software.
The Synopsis DWC2 IP inside STM32F4 is less capable than Chipidea HS inside LPC43XX. Chipidea one has embedded DMA who can transfer multiple packets without CPU intervention or...
Windows 10
RA family
src/portable/renesas/rusb2/hcd_rusb2.c
Also in other places under the portable directory.
__builtin_ctz function is not supported by IAR intrinsic which is used in the following:
src/portable/renesas/rusb2/hcd_rusb2.c
I am not sure if it is available under a different name. However, I would like to hear your opinion regarding this.
Thank you.
Just by compiling in ...
Describe the PR
Same test (reduced a little) on LPC55S69:
examples\device\cdc_dual_ports, except using simplified cdc_task() from examples\device\cdc_mscIAR should support the official ARM compiler language extension (ACLE) if the header arm_acle.h is included.
It does not contain __ctz (count trailing zeros). But __rbit and __clz. So you could try with:
#define __builtin_ctz(x) __clz(__rbit(x))
I defined it to the local function. I want to try the solution you have here. Thanks
I believe enabling DMA in the dcd_dwc2 driver would be beneficial for upping the transfer rates. Trying a throughput test with the standard ST middleware with DMA enabled I can get approximately 16MB/s throughput, as long as the data size is limited.
I'm afraid it will take me a considerable amount of time to get that working. Given the throughput rates you are reporting, I am considering using an NXP MCU in the future though ^^
Implemntation __builtin_ctz(x) for IAR , see issue #2060
Describe the PR
eliminate all the warnings for IAR host portable module for the Renesas RA family.
Additional context
Please see the table describing the __packed macro. This should work for ARM and RX families on IAR.
I only tested this on RA4M2 and RA4M3
Describe the PR
Hi facchinm,
Thanks for the PR.
Is Host tested on RA6M5 with Highspeed module? I would like to take the reference for the same.
@mcuenthusiast yes, the HS port has been tested in host mode too :slightly_smiling_face:
Thanks @facchinm for quick response
Just started to look at this more in-depth to understand what is happening.
Do I see the followings right?
How about make the cache related function optional (default ON) ?
For IMX.RT in order to have best performance, RAM will be configured to ITCM & DTCM, so they are accessed at CPU clock instead of bus clock (600MHz vs 133MHz)
Since TCM bypass the cache there is no need to flush or invalidate.
ah you are right, I think we can check the address to see if it is within the DTCM (non-cachable) and skip the clean/invalidate will update in the next push or so. Circuitpython is currently placing ehci_data and/or user memory randomly and may not be in DTCM.
Linux
Raspi Pico RP2040
My probe project (https://github.com/rgrr/yapicoprobe/tree/feature/systemview-rndis) uses lwIP / TinyUSB to provide a network interface for SystemView (https://www.segger.com/products/development-tools/systemview/).
The probe is running on a Pico (RP2040), the connected target board is an nRF52840. The nRF52840 generates the SystemView events (https://github.com/rgrr/playground/tree/feature/xray/tools/SystemView), th...
Hi sorry for late response, this is still on my radar. I was trying to get an RA6M5 EK to test with. However, that would probably takes too long (since I still couldn't decide what other stuffs to bundle get free shipping). I will review this in the next couple of days and test it on the hardware later on.
Describe the PR
Maybe a better, but possibly more elaborate idea for a probable solution:
@hathach isn't this correct and expected behavior? If the transfer did not finish with Zero Length Packet, the DCD layer should wait for more data.
Could we add a ZLP timeout? In case there is a transfer with length == MPS and there is no packet in the ZLP timeout, the DCD would notify TinyUSB about new received data
Hi @facchinm & @hathach
I have also tested this on USBFS RA6M5, It was working fine but sometimes It just gets stuck in below
condition due to hitting break point.
under function usbh_edpt_xfer_with_callback()
// Attempt to transfer on a busy endpoint, sound like an race condition !
line - TU_ASSERT(ep_state->busy == 0);
Any Idea what could be the reason or how could be be handled? any hints?
Improved HFCLK management for nRF5x with weak functions, the user can override and implement it's own HFCLK management, when other peripherials, such as Radio needs it.
Usage
User can override those functions:
void dcd_enable_hfclk(void); - called, when dcd requests HFCLK activation
void dcd_disable_hfclk(void); - called, when dcd requests HFCLK deactivation
If the functions are not overridden, HFCLK will be activated and deactivated by TinyUSB.
device controller driver
nRF5x
When SoftDevice is not present or is disabled, HFCLK activation/deactivation is managed by TinyUSB. This can cause problems, when other peripherials, such as Radio, needs HFCLK to run properly.
I have improved HFCLK management for nRF5x with weak functions, the user can override and implement it's own HFCLK management, when ot...
@Matt-prog Hi matt. Sorry to bother you, but would you be so kind as to tell me what version of the nrf SDK did you use with tinyusb? the latest one seems to be incompatible out of the box.
@tore-espressif indeed, it is specs on, and nothing wrong with current implementation.though it still causes some confusion for micropython user in the reference issue above. I was trying to see if we could find a way "resolve" this specially with CDC.
Windows 10
Custom STM32H747BGT6
Custom firmware with use of TinyUSB lib. Affected file: src/portable/synopsys/dwc2/dcd_dwc2.c
dcd_dwc2.c - function reset_core() halts in infinite loop after restart or power up of MCU. It happens at random times.
Present code:
static void reset_core(dwc2_regs_t * dwc2)
{
// reset core
dwc2->grstctl |= GRSTCTL_CSRST;
// wait for reset bit is cleared
// TODO version 4.20a s...
look great, thank you. For __packed can you try to compile with IAR -e option. It is a must since TU_ATTR_PACKED is used in lots of places other than this file
shouldn't the TU_ATTR_PACKED already covered the packed struct when complining IAR with extension flags -e
Yes, I am using the -e flag, for IAR workbench users it is under :
Options/ C_C++ compiler/ Language 1 / Language conformance / Standard with IAR extensions
I have the same question regarding TU_ATTR_PACKED, I thought it should be enough. However, I am using IAR compiler 9.1, which seems insufficient for these structs. When I use the __packed I am getting rid of the warnings. Here is IAR warning that I am getting:
 + 4$ shipping. Athough it is RA 6M3 but also have HS USB as 6M5. They will start shipping from June 5, it is probably better to wait for the board so that I could actually do the testing with the HW. Of course, unless @facchinm would prefer to have it merged first. Let me know ...
Hi @hathach,
thank you for the review! I am currently implementing the suggested changes. I moved the contents of the file dcd_nrf5x_cb.c to dcd_nrf5x.c. However, I would keep the header file (or rename it to dcd_nrf5x.h). This file can be included in the user .c or .cpp file with the definition of the "strong" functions. For the example, see here how I implemented it in...
This is a daughter PR from PR#2063
I am using the -e flag, for IAR workbench users it is under :
Options/ C_C++ compiler/ Language 1 / Language conformance / Standard with IAR extensions
TU_ATTR_PACKED is not solving the compiler warnings, I thought it should be enough. However, I am using IAR compiler 9.1, which seems insufficient for these structs. When I use the __packed I am getting rid of the warnings
Here is an example given by IAR, which somehow makes it seems that only __pac...
The root problem is not packed support, you can read more in #431
In this case since USB registers are 16bit aligned, there is no need to put TU_ATTR_PACKED at top level (for example stm32_fsdev also has 16bit registers), put TU_ATTR_PACKED in the bitfield struct level will make the purpose more clear.
Thanks for the response @hathach ,
will open the bug with more information, I also have one more issue with this port.
It will be great if you could guide me in understanding if it is actually the issue or not that before I open the issue.
Issue :- While sending the first command from msch_xfer_cb - case MSC_STAGE_CMD :- I am getting the stall response. and receiving the NRDY interrupt status.
This happens when I running the code on IAR, where as in e2studio with same code I don't...
@mcuenthusiast just open a new issue, we could discuss there.
@mcuenthusiast in fact I've been only testing the patch on e2studio (gcc)
@HiFiPhile The workaround is suppressing the warnings, but sometimes you can not use it, for example:
return ((volatile uint16_t*)(RUSB2)+ offsetof(RUSB2_REG_t,PIPE_CTR[num - 1]));
here it is throwing an error because "num" is not a constant. __packed suppress all the warnings, I have tested it, seems to work, I am not sure if we can use the following :
#define TU_ATTR_PACKED __packed
instead of:
#define TU_ATTR_PACKED attribute ((packed))
for the IAR...
I'm agreed IAR has some problem handling packed struct, behavior of __attribute__ ((packed)) and __packed should be the same, either:
Could you try to change packed keyword into bitfields level, such as:
typedef struct {
union {
volatile uint16_t E; /* (@ 0x00000000) Pipe Transaction Counter Enable Register */
struct TU_ATTR_PACKED {
uint16_t : 8;
volatile ...
Describe the PR
@HiFiPhile Could you try to change packed keyword into bitfields level?
I did, the warning is still there, but when I use __packed it is suppressing the warnings for sure. I have tested it. The commit in this PR is getting rid of the warnings for sure. The only I am thinking of, if there is a neater way to put it in
behavior of attribute ((packed)) and __packed should be the same.
I agree with you on this, but the compiler doesn't see it this way from my side. The compiler is not doing anything with this attribute ((packed)), maybe in the newer IAR compiler it is not supported or ignored, I don't know
Is this issue also present in the host module, I am assuming from a quick look it is there as well.
Didn't check the host, though I think it might not be a problem there as the host is driving the communication. On the device side, the problem manifests due to the host asking for data (without prior notice to prepare it), which needs to be served (which may take time to prepare, requiring the work of other modules).
I applied a patch locally, following my second suggestion of adding an interface to signal data readiness. It took just a few dozens of lines in the MSC device class (header ...
MacOS
Raspberry Pi Pico
Based on UAC2 headset example, extended to have 2 UAC2_Headset devices
The headset example works as expected.
I have two UAC2 devices running.
I did, the warning is still there
In my test there is no more warning moving TU_ATTR_PACKED to the bitfield struct level.
But since RUSB2_REG_t heavily use bitfield, I feel like adding TU_ATTR_PACKED everywhere is not elegant.
@hathach what's your opinion?
Describe the PR
Description
The documentation in msc_host.h specifies that:
// Check if the interface is currently ready or busy transferring data
bool tuh_msc_ready(uint8_t dev_addr);
An interface can be busy either receiving or sending data. The current code contemplates only the data reception, but not the data transmission.
See the following example for reference:
``...
In my test there is no more warning moving TU_ATTR_PACKED to the bitfield struct level.
Yeah, we should move the packed to bitfield if that fixes the issue. And also having TU_VERIFY_STATIC() to make sure the size of the whole struct is correct as well.
But since
RUSB2_REG_theavily use bitfield, I feel like adding TU_ATTR_PACKED everywhere is not elegant.
I don't real...
thank you for your PR, I slightly move the check for status_change not zero to make it clearer. Will merge when ci passed.
Short sign of live: Other project finally finished and I will try it this week. Sorry for the long dealy.
After #2016 merged, I'm getting Data Seq Error when LOG=3 which is the same error when LOG=0. So at least it is consistent.
Here are the logs when I power up with the hub already plugged in:
usb-hub-setup.txt
and then after I plug in the B100 Logitech mouse into the hub:
(ignore ALL: Resetting devices lines, as that is part of my code)
[usb-hub-connect-mouse.txt](https://github.com/hathach/tinyusb/files/1160284...
this should be fixed in recent imx usb host improvement PR. Would you mind testing it again with master.
may be fixed by recent ehci PRs. Please try testing it again with master.
Originally posted by Commotari May 24, 2023
in function tud_hid_n_report the length is getting limited according the bufferlength "CFG_TUD_HID_EP_BUFSIZE" that is configured in tusb_config.h.
if using the function with bigger package lengths of course it does not work. but also it does not tell that anything went wrong.
it just sends the package out with a limited length and returns success.
on my windows appl...
Just tested on current master, it seems to be fixed. Thank you!
Just tested on current master, it doesn't crash anymore. Thank you!
Describe the PR
minor cmake update for flto along with indent (2 spaces), add bin hex output function
thank you @HubertD very much for this brilliant port, and @HiFiPhile for improving/enhancing and testing with actual hardware. I have pull and tested this on my https://www.st.com/en/evaluation-tools/nucleo-g0b1re.html . The driver works great, USB enumerates and works as it should be.
However I have to changes the clock setup to use HSI48 (on B1) for USB device to run (existing code doesn't work with B1). @HiFiPhile maybe we should seperate the B0 to its own board, since it seems to lack...
However I have to changes the clock setup to use HSI48 (on B1) for USB device to run (existing code doesn't work with B1).
It must be because of this (I don't even remember when I soldered SB17), since B0 doesn't have CRS HSE must used.
Maybe no need to separate B0 board, just put a word to solder SB17 for B0 user.
Let me know if you are still planning to update this PR more, and p...
yeah, ST doesnt make nucleo B0 version, you probably the only one that would rework the chip and solder the SB17. That is amazing soldering skill, I struggle enough with only soldering SWD occacsionally :D . I will keep the clock and also added the note for B0, at least that would give you an easy way to modify the code to test with your board. I am trying to add USB PD support, therefore want to get G0/G4 up to date before doing more works to prevent conflict in the future.
That is amazing soldering skill, I struggle enough with only soldering SWD occacsionally :D
In fact my job title is more like a hardware guy ;) Sometimes I even need to re-plant solder balls of eMMC chip :D
I am trying to add USB PD support
You mean the whole PD stack ? Seems a lot job to do.
In fact my job title is more like a hardware guy ;) Sometimes I even need to re-plant solder balls of eMMC chip :D
That sounds like awesome (awful) job to me :smile:
You mean the whole PD stack ? Seems a lot job to do.
yeah, I went through the specs recently, it is lots of works. But i will try to get the PD sink work first, to at least request an vbus = 12v or 20v first with PD controller on G0/G4 then try to bit-bang it with rp2040 (gpio or pio). That is a long way to go.
Diagnostic printf format string was missing %u, fixed.
Originally posted by mkarliner May 26, 2023
MacOS
Raspberry Pi Pico
Based on UAC2 headset example, extended to have 2 UAC2_Headset devices
The headset example works as expected.
I have two UAC2 devices running.
Help with debugging by labeling the tinyUSB event queue.
Makes the queue visible to debug windows FreeRTOS task and queue.
I think this is one of those good new / bad news situations...
Good news:
I got it working and of course in the end adapting my code was easy (after spending a few hours searching for the little difference in my descriptors that prevented it from working immediately). So, I think the pull request is good.
Bad news:
I did not manage to achieve a significantly higher frame rate. In contrast to the isochronous mode the UVC driver accepts a 30fps stream in bulk transfer mode, but when I r...
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.
Okay, I think I figured it out. It is a little bit strange but __packed on the higher struct level suppresses the warnings, but attribute ((packed)) only works on the bit field level. To maintain the TU_ATTR_PACKED, I agree with Hathach that maybe it is better to put it on the bit field level and solve the problem. I will rework this PR.
Re-opened thanks @kholia for explanation, I will re-evaluate this later on
I thought of same use case. Pi zeros have only one USB port.
I am having an issue with the current implementation of the osal_task_delay function. It was also not stable if you are trying to connect and disconnect the USB device very fast. This will make it possible to override the function to your implemented delay function. Otherwise, it will keep the current implementation.
Describe the PR
This PR moves helper macros from tusb_common.h to separate file so it can be included from tusb_types.h.
This is needed for situations when user needs to include only types without the rest of the stack.
It is useful mainly for writing libraries using TinyUSB as a dependency.
Curently there is no way to import only types from a library without having a stack set up.
Additional context
I am writing a small [library](https://github.com/tomas-pecserke/pico_tus...
can you elaborate your code and the issue you are encountering.
Hello rgrr,
The same thing has been observed on my platform. RNDIS performance is fairly reasonable, But NCM is 10 times slower then RNDIS.
My Prime suspect is the way NTB is handled
Also there is a bug in the implementation which I filed sometime ago but still haven't got any response yet.
Hello joshikeval3131,
to be honest, I'm more or less a novice to (Tiny)USB from developer side. Do you have some pointers where and how to start debugging the NCM code? Of course I have found ncm_device.c et al, but even adding some debug output still generates more confusion than clarity.
look good, though can we still keep the TU_ATTR_PACKED of the overal srtuct ? this is just to prevent any padding between sub-struct member ?
look good, though can we still keep the TU_ATTR_PACKED of the overall struct? is this just to prevent any padding between sub-struct member?
For some reason, the compiler will keep the warnings, if I do that. This is why I have removed them
Expect dma capability in dwc2
look good, though can we still keep the TU_ATTR_PACKED of the overall struct? is this just to prevent any padding between sub-struct member?
For some reason, the compiler will keep the warnings, if I do that. This is why I have removed them
I see, what I interperte is the bit-field struct is packed -> size = 2, however, since the global struct is not packed, it is techically valid if compiler inserted padding between 2 struct/union e.g to have each 4-byte aligned. Since the glob...
look good, though can we still keep the TU_ATTR_PACKED of the overall struct? is this just to prevent any padding between sub-struct member?
For some reason, the compiler will keep the warnings, if I do that. This is why I have removed them
I see, what I interperte is the bit-field struct is packed -> size = 2, however, since the global struct is not packed, it is techically valid if compiler inserted padding between 2 struct/union e.g to have each 4-byte aligned...
Is there any more information I can give to help with resolving this issue?
not sure how this would have worked for any of the others either
should be no issue, though I found that for cmake, we don't need TOP to be absolute path as with makefile. Do pi example requires TOP to be absolute to build ?
Comment-only change.
Second alternative should has index 1.
When I run "examples\device\cdc_msc_freertos" on a stm32h743nucleo, and I disconnect the USB, then tud_suspend_cb() (slow blinking) gets called instead of tud_umount_cb() (fast blinking). Seems to be the same bug
thanks for the context, I will try to revise the include hierachy and/or review this later on.
@hathach is there anything I can do to speedup the merge :slightly_smiling_face: ?
should be no issue, though I found that for cmake, we don't need TOP to be absolute path as with makefile. Do pi example requires TOP to be absolute to build ?
Well you changed TOP from ${CMAKE_CURRENT_LIST_DIR}/../../.. to ${CMAKE_CURRENT_LIST_DIR}/../.. when you moved it to the parent family_support.cmake.
All the uses are a directory deeper ${TOP}/some_file whic no longer matches up. I figured if you wanted TOP to be usable anywhere in that sub-tree I'd make it absolute. ...
@facchinm you have done wonderful works. Though since I am still waiting for rt-thread to ship my order. I haven't looked at this pr changes yet. I have asked them about the shipment (ETA is June 5th). If it is blocking your works. We could review it first and do the hand-on tests later on. Sorry for the delay so far.
Update: The rp2040 zero issues seem to be separate (seems like they don't boot fullstop after disconnecting); the issue with tiny_usb devices not showing on the steno board persist though; and are intermittent.. most times it doesn't work; but when connecting to a sleeping machine, it seems to be able to wake it up most of the time, then work correctly after.
I am sorry to bother you but I got the same problem with you, I have 3 RP2040-Zero from WaveShare, only 1 works, the other...
Going to close this; ended up being a flash spi clkdiv issue.
OK, I find the reason and submit a fix to the pico-sdk: https://github.com/raspberrypi/pico-sdk/pull/1421.
No worries, take your time :slightly_smiling_face: Thanks for the amazing work!
good news, they already shipped my package, it will probably arrive in several days.
Describe the PR
Initial support for USB PD stack tested with STM32 G4. Able to communicate via CC channel to:
retrieve Source Capabilities from a charger
PD Source Capabilities
[Fixed] 5000 mV 3000 mA
[Fixed] 9000 mV 3000 mA
[Fixed] 15000 mV 2000 mA
[Fixed] 20000 mV 1500 mA
Able to request power to supply 5v, 9V and 15V (which is maximum B-G474E-DPOW1 can withstand).
Although possible, this PR didn't tested USB communication along with PD.
API is all very ...
wow you are super fast 😄
Purpose: This example provides a composite CDC + UAC2 device on top of a Raspberry Pi Pico board.
Closes: https://github.com/hathach/tinyusb/pull/1717
Motivation:
The CDC + UAC2 composite device happens to be important, especially in the amateur radio community.
Modern radios (rigs) like Icom IC-7300 + IC-705 expose a sound card and a serial device (composite device) to the computer over a single USB cable. This allows for Audio I/O and CAT control over a single USB cable whic...
I have opened https://github.com/hathach/tinyusb/pull/2105 now. All feedback is welcome - thanks!
If you interested in making this a full project with board and case designs I'd be interested in joining.
If you interested in making this a full project with board and case designs I'd be interested in joining.
One of the points of this work is to power various radio interfaces over a single USB cable without even touching the soldering iron (and those LQFP48 chips), if desired.
This being said, let's see what the future holds - thanks!
wow you are super fast smile
I am only scratching the surface, PD defines lots more message, also allow swapping data role, effectively making OTG obsolete. Anyway, this only allow device to request higher operating voltage, which is handy and probably most user want to have higher VBUS with typec charger (finally get rid of the DC Jack). There is still lots more works.
Hello, nice to view that this example is useful for so many people. Any changes or corrections you need I will be following this thread. Thank you.
Some device can generate multiple event attach/detach/attach (bounching) when plugging into usb host. These are literally generated by physical contact which could cause issue with usbh.
Symptom would be seeing USBH Defer Attach until current enumeration complete all over.
This Issue has been resolved now
would you mind sharing the info that help to resovle this issue.
Describe the PR
Describe the PR
Superb! Thank you @kkitayam very much again for this excellent works. Thank @Staacks for testing it out. Although it doesn't got a faster rate but it looks great. Maybe we are missing something, but this is more than enough for the merge. Thanks again and sorry for late response so far.
@hathach Thank you for fixing this. I have a question also regarding getting stuck in the enum process.
It happens to get stuck for me in the same part also when I try to attach old MSC devices, I am not able to figure out why yet. Did you notice this behavior or was it reported before?
I encounter this issue when working on imx host, though each port will be different. This pr only fixes the issue in usbh, if you are still seeing the issue, it can come from the hcd layer. Feel free to open an discussion or bug issue to provide more detail as well as further analysis.
About that rate: I did not test with a minimal project, but I suspect that this is an issue particular to my project as the rp2040 has quite a lot to do in that case and probably misses a few chances to transmit data when tud_task is not called in time. I am currently working on a method to achieve 60fps via MJPEG encoding (thanks to a very clever idea someone suggested to me) and I am having the exact same problem: I managed to encode 160x144 JPEGs at 60fps, but I have not yet succeeded to...
A bunch of amateur radio folks are super interested in this functionality.
https://github.com/je1rav/QP-7C_RP2040_CAT - Here is another (not-complete-yet) attempt at doing so. By joining forces, and with an upstream-first approach, we should be able to get closer to our target.
thanks @kholia , I will review this as soon as I could.
Describe the PR
Describe the PR
correct Cmake build iar
Windows 10
stm32f401blackpill
Custom firmware STM32Arduino and Platformio based.
Main contains the additional required code to set he GPIO pinmux, and VSENSE is disabled via:
#include
#include "tusb.h"
// Pinmux for USB not exposed by core variants !
const PinMap PinMap_USB_OTG_FS[] = {
{PA_11, USB_OTG_FS, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_OTG_FS)}, // USB_OTG_FS_DM
{PA_12, USB_OTG_FS, STM_PIN_DATA(STM_...
There is a bug https://github.com/hathach/tinyusb/issues/1945 about the same issue but is not clear how I should use dwc2.
add src/portable/synopsys/dwc2/dcd_dwc2.c and remove the other st driver.
add src/portable/synopsys/dwc2/dcd_dwc2.c and remove the other st driver.
so the only way is to to modify the imported library? (git submodule)
Describe the PR
I tested using picosdk/lib/tinyusb/examples/host/bare_api almost as is for communication with Dynastream ANT-USB-m in a rp2040 /pico-w environment and found that incorrect memory access is occurring during the debugging device information output process.
I believe this is due to some misconfiguration and are still analyzing the problem, but I have added a check for cases where the result of tuh_descriptor_get_manufacturer_string_sync is not retrieved to prevent illeg...
Is the work on this still active? MIDI host support would be quite useful for a project I'm working on
Describe the PR
Add etm trace for supported boards:
can you provide log and/or try to place an breakpoint to analyze why the string descriptor is empty. Also which string index it is reading, and what is the real value of that string e.g when plugging into PC.
look great, thank you for the fix
spot on, thank you for the fix
[HOST] Quit the joystick test app.
[HOST] Run the HID test app.
There is nothing tinyusb lib can do to fix this scenario, the report is delivered to PC host. Host decides not to forward past event to test app or test app simply does not query those events is out of each for a usb device. You can mix both approach by having an periodic timer with reasonably large enough timer
Great, thank you for your update and explanation.
[HOST] Quit the joystick test app.
[HOST] Run the HID test app.There is nothing tinyusb lib can do to fix this scenario, the report is delivered to PC host. Host decides not to forward past event to test app or test app simply does not query those events is out of each for a usb device. You can mix both approach by having an periodic timer with reasonably large enough timer
Good to know - thank you for your insight on this matter, much appreciated.
This fixes the handling of HID input and output interrupt reports in tinyusb, which are currently conflicting with get feature and set feature reports.
HID supports "get feature" and "set feature" reports over ep0 (control endpoint).
HID also supports "input" and "output" reports over endpoints specified in the hid interface section of the configuration descriptor.
Currently tinyusb uses the same buffer 'epin_buf' for output reports and get feature reports.
It also uses the same buffe...
update: package from rt-thread is still nowhere to be founnd. My exp with postage is if it does not make it in a week or two, it will take a month or two. I loose the patient and order an renesas 6m5 dev kit from digitkey, all thanks to Adafruit's sponsorship. Digikey has shipped, hopefully we could review/test/merge this next week.
Now that the product is available we can also send you a Portenta C33 (just drop me an email :wink: )
From the UM of RA PID can show 2 or 3 if it is stalled. I already ran into a situation that I was getting 3, in nrdy status.
RA PID can also show 3 if it is stalled
Now that the product is available we can also send you a Portenta C33 (just drop me an email wink )
sound great, I would love to test out C33 as well. What is your email, though. I can't find it in your profile. If you don't want to state it public, you could send me an email first, Mine is in github profile
when I ran RA in host mode for MSC, I have an issue with old sticks, during the enumeration process I am entering into stall state (PID = 3). I am not sure how it can be solved. Here is my debug message after this PR fix
Add board support for STM32F407VETx, based on stm32h745disco. The USB PMA differs from other F4 family.
Board descriptions at https://github.com/mcauser/BLACK_F407VE and https://os.mbed.com/users/hudakz/code/STM32F407VET6_Hello
Windows 10
imxRT1024 custom (USB same as EVK board)
tinyUSB main as of noon EST 24-June-2023.
arm-none-eabi-g++ (GNU Arm Embedded Toolchain 10.3-2021.10) 10.3.1 20210824 (release)
Copyright (C) 2020 Free Software Foundation, Inc.
Application is essentially msc_file_explorer example (FreeRTOS).
If the application is started with the USB stick already plugged in, it works fine.
A MassStorage device is mounted
D...
Describe the PR
Refactor make/cmake build system
If you have evk, please test it with evk. And absolutely need to test with stock example without freeRTOS, and 99% same firmware are still 2 different firmware.
Describe the PR
auto detect FAMILY based on BOARD
Describe the PR
minor rp2040 clean up
Thank you for your comment,
I had tried following debug in a rp2040 /pico-w environment.
And I am currently working on an implementation without using the tuh_descriptor_get_manufacturer_string function.
Thread 1 hit Breakpoint 1, tuh_descriptor_get_manufacturer_string_sync (daddr=daddr@entry=1 '\001', language_id=language_id@entry=1033,
buffer=buffer@entry=0x20041e48, len=len@entry=256) at /home/dsugisawa/git/pico-sdk/lib/tinyusb/src/host/usbh.c:1081
1081 {
(gdb) c
Co...
Describe the PR
Part of series to get freertos support with cmake build system for rp2040
Thank you for making PR, after doing quite a bit of works to support cmake, I am getting better with it. I agree that adding tinyusb_device_freertos and tinyusb_host_freertos is best approach. Though I think we should do it in pico-sdk, I also think the freertos-kernel lib should be also added there rather than within tinyusb. That will help pico user by just simply link with freertos-kernel and or tinyusb_device_freertos. Check out my PR to pico-sdk here https://github.com/raspberrypi/pico-s...
New evidence for the NCM problem.
I have done some tests with the iperf server provided in the lwIP examples and recorded with Wireshark.
Once I have done the tests with ECM and once with NCM. iperf command line on client side (Linux) is
for MSS in 90 93 100 150 200 255 256 300 400 500 511 512 600 700 800 900 1000 1100 1200 1300 1400 1450 1459 1460 1500; do iperf -c 192.168.14.1 -e -i 1 -l 22 -M $MSS; sleep 10; done
Wiresharks statistics graphs are as follows.
Good case is ...
good idea, though tinyusb has seperate queue for device and host, we should take that into consideration as well. "usbd"/"usbh" string should be added to OSAL_QUEUE_DEF() as queue name. Would you mind making the change, no worries if you don't have time, I could make change myself later when possible
I think the best way is to declare it as a weak function that can be implemented by user, or keep the current implementation . See #2093
Hi, any update on this ? we're ready to merge support for the new board in MicroPython but it's blocked by this (see https://github.com/micropython/micropython/pull/11405). Are there any standard tests that we can maybe run for you instead ?
Hi, any update on this ? we're ready to merge support for the new board in MicroPython but it's blocked by this (see micropython/micropython#11405). Are there any standard tests that we can maybe run for you instead ?
I am still waiting for my 6m5 dev kit, it is probably delivered in a day or two. Then we could start reviewing & testing, if everything go well, we could merge this mid-next week or so.
Describe the PR
Fix some small spelling issues
@hathach - I added queue name to OSAL_QUEUE_DEF() as you suggested and clarified queue names to make debug easier. Hope its OK!
look good, thank you
Describe the PR
Implement hcd_frame_number() for pio-usb host, need https://github.com/sekigon-gonnoc/Pico-PIO-USB/pull/88
Hmmm, does anybody read this?
I want to make a proposal: the ncm_device driver seems to be very buggy, e.g. it operates on incoming frames while the previous one is still processed, also it does no ZLP insertion where it should insert one. These bugs are the cause for the above described hickups.
I have implemented a simple version of the driver, which allows only one ethernet frame on reception/transmission.
This would put the focus on reliability, not so much on performance.
If...