I'm pretty sure that low-speed USB devices aren't allowed to have bulk endpoints, which rules out typical CDC ACM implementations, so this concern probably doesn't apply.
Perfect! Thanks for the info. :)
1 messages · Page 5 of 1
I'm pretty sure that low-speed USB devices aren't allowed to have bulk endpoints, which rules out typical CDC ACM implementations, so this concern probably doesn't apply.
Perfect! Thanks for the info. :)
Linux
NUCLEO-WL55JC1 (STM32WL55 with LoRaWAN, but no internal USB controller), external MAX3421 as host
own firmware running on STM32 based on STM32CubeWL Firmware Package v1.3.0
I've maybe found a bug, but I'm not sure...
My application: STM32 with MAX3421 and TinyUSB host communicating with attached CDC device (RS232)
The issue: CDC Tx bulk transfers are lost depending on timing relationship of Rx/Tx bulk tranfers
I...
Linux
OHCI
host/hub.c (ae364b1460b91153cd94b4b0303eeda6419ff1d1)
When connecting a device to my downstream hub I hit usbh_edpt_xfer_with_callback 843: ASSERT FAILED everytime
// Attempt to transfer on a busy endpoint, sound like an race condition !
TU_ASSERT(ep_state->busy == 0);
Ive tracked down the issue to this area
h...
Describe the PR
Fixes the issue discuessed in https://github.com/hathach/tinyusb/issues/2399
Describe the PR
Fixes issue we discussed way back in https://github.com/hathach/tinyusb/issues/1497
[Ryzee119]commented [on Jun 8, 2022]
I will create a PR for this fix soon
heh :upside_down_face:
Additional context
This now allows 256 EDs, and >=127 devices as per USB spec. This should cover pretty much anyones needs while keeping a few bits in the TD structs for future use.
The extra array will likely help with iso transfers which I am look at now as we likely ...
on further inspection is seems an 'issue/oddity' with my hub which causes a different code path than 'normal' and is perhaps why this hasnt been noted to date so reproducing might be challenging.
This hub sets the change.port_enable bit interrupt, none of my others do
Doing RMW (read-modify-write) operations on interrupt status bits is always broken because the interrupts, which become pending during the RMW operation, are cleared without being processed. The same issue is discussed in details in https://github.com/libopencm3/libopencm3/issues/392.
This particular bug was introduced with commit 412b557 by @HiFiPhile . I'm noting it to just serve as a reminde...
Thanks for your PR, indeed I missed ISTR register is rc_w0.
Could you give me more details about your usage case, because the issue is not caught in stm32l412 HIL test setup and our stm32l072 board in mass production ?
In my case it's a custom self-powered device based on STM32L432KBU6, which implements a single MSC class device. There is no RTOS, just a simple cooperative scheduler. The compiler used is GCC v10.3. With O0 the USB often (but not always) worked, but with Og, O1 or anything higher it basically never worked. The TinyUSB log showed that the stack issues too many resets (more than the 3 typical ones). It could be that the fine timings are specific to the host PC. In that case the PC is a rather ...
Took a look on that failed test for F1 series. It fails because the registers on F1 are defined as 16-bit. Just adding a cast to uint16_t doesn't seem future proof and actually H5 series already have some status bits above the bit 15. Maybe it's worth introducing some typedef fsdev_register_t, which should be defined to uint16_t for some series and uint32_t for all the other by default?
Maybe it's worth introducing some typedef fsdev_register_t, which should be defined to uint16_t for some series and uint32_t for all the other by default?
I agree. I believe since G0 the IP upgraded to support host operation and ISTR grows to 32 bit.
changed RTS/DTR bit descriptions to enums CDC_CONTROL_LINE_STATE_RTS, CDC_CONTROL_LINE_STATE_DTR
Hi there @hathach I wanted to see if this had been looked at as a possible addition to TinyUSB? We are still maintaining a local callback/hack in the GP2040-CE firmware to support this on GET FEATURE reporting.
Hey gang, I got STM32H503 with TinyUSB working by removing MX_ICACHE_Init() from main.c
(there might be a timing error - see https://community.st.com/t5/stm32-mcus/how-to-use-stmicroelectronics-classic-usb-device-middleware-with/ta-p/599274?lightbox-message-images-613409=61313i4F7537BE778740F2)
Also I had to change the code in "dcd_stm32_fsdev_pvt_st.h"
Lines 217 and to 230 USB_DRD_BASE -> USB_DRD_FS_BASE
stm32h5xx_it.c
/**
Describe the PR
If you disconnect a USB hub tusb clears the hub device memory (to zeros). If its a hub, during disconnect it also creates a detach event on hub port 0 to unroll the loop. Problem occurs when it processes this detach event on the now cleared hub device and requests the next hub status packet
Resulting in this request onto the hub interrupt endpoint
`Queue EP 00 with...
moved CDC host options CFG_TUH_CDC_LINE_CODING_ON_ENUM & CFG_TUH_CDC_LINE_CONTROL_ON_ENUM to tusb_option.h
set pretty defaults
and the code is better readable now
before the requested baudrate was stored in global variable _ftdi_requested_baud.
for clean baudrate setting it's necessary to store the requested per device.
set coding on enumeration is optional. not defined it will skip the set request. This PR alternate that behavior and therefore not accepted.
OK, but I don't understand why TU_ATTR_FALLTHROUGH is always active and not after #else in acm_process_config()
This PR addresses a bug I discovered on stm32f7 when using the OTG_HS dwc2 peripheral with the internal FS phy while also using tickless idle with freertos. The problem is identical to the issue described for the H7 series, but on the F7 different bit names are used. This patch also disables the ULPI clock during tickless idle for stm32f4 and stm32f2 series microcontrollers that have the OTG_HS peripheral. While I did not test the other MCUs, I don't see how this could harm since with this pa...
host stack
rp2040
When the pio support is enabled the native version doesn't work because pio version have redefinition on some functions that doesn't work on native version. There are cases where is necessary to switch from a mode to the other to take advantage from the pio space free when use the native version.
Merge the initialization functions of nat...
Reviewed all of the related ST reference manuals and header files and found out that the following factors are equal for all devices:
As registers and PMA are accessed through the same bus interface, most likely access width is limited by the bus interface itself. The access width is 16-bit for all older devices and 32-bit for the newer G0, H5, U5. That means the `PMA_...
Added a commit with a new
fsdev_bus_ttypedef. As now those identifiers would serve not just for PMA description, but as a generic FSDEV hardware implementation parameters, for the sake of consistency I would also rename these:
PMA_32BIT_ACCESS=>FSDEV_BUS_32BITPMA_LENGTH=>FSDEV_PMA_SIZEShould I add such a commit also or leave those as is?
yeah, please do it while we are here
As registers and PMA are accessed through the same bus interface, most l...
TU_ATTR_FALLTHROUGH is a hint to compiler, not an actual statement.
added useful log of vid/pid in tuh_vid_pid_get()
added missing CR/LF after TU_LOG_MEM
superb! Thank you very much for improving the ohci driver. There are some minor things, that I have notice. I take the chance to add cmake support to lpc17 to test out the PR. I have push some update to
Please let me know if these changes make sense to you.
Note: I haven't tested on actual hardware yet, if you have time please do on your side. We can merge this once tested.
minor but could you change from intptr_t to uintptr_t
since extra data is on its own, we should have have expected_byte as the whole uint16_t, that would help to reduce bitmask op by compiler. Should we need extra info, we can have it as bitfield or just add more field as needed.
this still potentially waste a bit of sram since compile will do padding to have ED 32 bytes algined resulting to 30*number of control bytes. We should move after all ED/TD declaration e.g
gtd_extra_data_t gtd_data[GTD_MAX]; // extra data needed by TDs that can't fit in the TD struct
gtd_extra_data_t gtd_control_data[CFG_TUH_DEVICE_MAX+CFG_TUH_HUB+1];
it is a bit ugly, but worthy to save as much sram as possible
@hathach After more tests this PR is ready.
can you do the #ifdef #else instead of undef (ust move this up). undef is rather confusing since people may only look at the first define.
thank you @kkitayam for reviewing changes in video example. I checked the UART changes to f103 bluepill, look good to me. I made an push to fix compile with other f1 board without uart defined.
Renamed the macros along with a few minor changes. I guess this PR is now ready to go.
By the way... @hathach and everyone involved, thanks for a decent USB stack! In my opinion this project is on a path to become what the FreeRTOS is for RTOSes and lwIP for IP stacks - the number one choice.
look good, even though there is tons of other weak functions. We can migrate/update them later on so that it would work with keil better.
Describe the PR
A stack address which arrived via a parameter may be assigned to a non-local variable.
Youre right this a good pick up. Thanks
Looks like you beat me to the changes. Good pick ups
I have tested on hardware is all is working great. I tested with 17 devices + 3 hubs :fire:
HID MOUNTED 01 0
START HID
A device with address 1 is mounted
HID MOUNTED 02 1
START HID
A device with address 2 is mounted
HID MOUNTED 03 2
START HID
A device with address 3 is mounted
HID MOUNTED 04 3
START HID
A device with address 4 is mounted
A device with address 5 is mounted
A device with address 6 is mounted
A device w...
superb! thank you for your Pr and testing it out. this is good to merge now.
Just to clarify @hathach
Like this?
#if defined(__GNUC__) || defined (__clang__)
#define TU_ATTR_ALIGNED(Bytes) __attribute__ ((aligned(Bytes)))
#define TU_ATTR_SECTION(sec_name) __attribute__ ((section(#sec_name)))
#define TU_ATTR_PACKED __attribute__ ((packed))
#if defined(__GNUC__)
#define TU_ATTR_WEAK __attribute__ ((weak))
#else
#define TU_ATTR_WEAK __attribute__ ((weak_import))
#endif
... ...
yeah, but the otherway around
#if defined(__clang__)
#define TU_ATTR_WEAK __attribute__ ((weak_import))
#else
#define TU_ATTR_WEAK __attribute__ ((weak))
#endif
@thewh1teagle actually this PR will soon be two years old, but no worries as it's already available on rp2040 and esp32 various core versions so it's very likely it has been tested in live projects and doesn't need to wait for sponsor approval.
If you need to implement that outside the tinyusb source tree just let me know and I'll happily help.
Describe the PR
Adds support for TUSB_REQ_FEATURE_TEST_MODE feature in usbd.c
Additional context
Added callback functions tud_test_mode_req_status_xfer_cb(), usbd_set_test_mode() and dcd_set_test_mode() that are
called to transition the USB device into the electrical compliance test mode.
added CDC specific debug logs in new file cdc_debug.h
initial version with logging of line_coding
later also logging of line_state and other useful infos like serial state after this PR is accepted
added to CDC host and tested
added to CDC device, but inactive (#if 0) and to test later
A type-C switcher allows to programmatically connect two devices pin-by-pin, rather than using a HUB).
Some USBC0 to USBC1, or some USBC0 to USBC2, either at a time.
https://www.digikey.com/en/blog/introducing-the-ultimate-usb-type-c-switch
https://www.codethink.co.uk/articles/2019/codethink-creates-custom-usb-3-switch-to-support-customers-cicd-pipeline-requirements/
This can help to automate host-mode operation:
@josuah
Thanks for your interest in HIL test.
A port switcher is not the priority, as currently all boards has a debugger attached who can read test results.
Currently all boards in the loop are bought by me or hathach, without a sponsorship we can't test all kinds of configurations.
Thinking again, if wanting to leave all boards connected at all time for an automated test script, a switcher of only the D+/D- and +5V lines would be a good compromise.
A port switcher is not the priority, as currently all boards has a debugger attached who can read test results.
Noted! This sounds like a better solution indeed.
For practical setup, regardless of the solution used, here is something that scales well and is cheap and quick to do:
;
cdch_interface_t* p_cdc = get_itf(idx);
can also moved to
process_internal_control_complete()
I'll push proposal soon...
& 0x00ff no more necessary?
I advise not to change that. There are explicit instructions that default line coding is necessary to start up the CH34x. For this reason I created
CFG_TUH_CDC_LINE_CODING_ON_ENUM_CH34X. It may happen, that the following steps 'CONFIG_CH34X_SPECIAL_REG_WRITE' etc. will not work properly. see* https://github.com/torvalds/linux/blob/c25b24fa72c734f8cd6c31a13548013263b26286/drivers/usb/serial/ch341.c#L386 * inital 9600 Bd write https://github.com/WCHSoftGroup/ch341ser_...
may or may not, I remembered it cause narrow down warnings from gcc which is treated as error build.
here we already set the line coding, it should be set right away, since there could be error in the middle steps.
I advise not to change that. There are explicit instructions that default line coding is necessary to start up the CH34x. For this reason I created
CFG_TUH_CDC_LINE_CODING_ON_ENUM_CH34X. It may happen, that the following steps 'CONFIG_CH34X_SPECIAL_REG_WRITE' etc. will not work properly. see* https://github.com/torvalds/linux/blob/c25b24fa72c734f8cd6c31a13548013263b26286/drivers/usb/serial/ch341.c#L386 * inital 9600 Bd write https://github.com/WCHSoftGroup/ch34...
Hi @Rocky04, do you have any more thoughts about enabling opt-out for this feature through a #ifdef? Are you planning to add this to usbd.c? Some of the tests are also failing in the compilation stage. I don't see how these changes can fail compilation.
@shuchitak
The build error looks to me like a configuration problem, it appeared while I haven't really changed the code.
CMAKE_C_COMPILER_VERSION not detected. This should be automatic.
-- Configuring incomplete, errors occurred!
For the code exclusion I currently favor to use a symbol and if that is defined to not compile the code in the first place. Because I prefer an opt-out for it and keeping it as simple as possible.
I advise not to change that. There are explicit instructions that default line coding is necessary to start up the CH34x. For this reason I created
CFG_TUH_CDC_LINE_CODING_ON_ENUM_CH34X. It may happen, that the following steps 'CONFIG_CH34X_SPECIAL_REG_WRITE' etc. will not work properly. see* https://github.com/torvalds/linux/blob/c25b24fa72c734f8cd6c31a13548013263b26286/drivers/usb/serial/ch341.c#L386 * inital 9600 Bd write https://github.com/WCHSoft...
I advise not to change that. There are explicit instructions that default line coding is necessary to start up the CH34x. For this reason I created
CFG_TUH_CDC_LINE_CODING_ON_ENUM_CH34X. It may happen, that the following steps 'CONFIG_CH34X_SPECIAL_REG_WRITE' etc. will not work properly. see* https://github.com/torvalds/linux/blob/c25b24fa72c734f8cd6c31a13548013263b26286/drivers/usb/serial/ch341.c#L386 * inital 9600 Bd write https://github.c...
perfect, the PR is well tested and is optimized for ch34x support. Thank you very much for your patient and following up to my request as well as my modification. I am glad that we are finally getting this merged.
My problem in #2377 is also fixed with this MR!
perfect, the PR is well tested and is optimized for ch34x support. Thank you very much for your patient and following up to my request as well as my modification. I am glad that we are finally getting this merged.
Thank you, I enjoyed working with you and learned a lot.
I will be doing compatibility tests with the master version in the next few days.
@hathach Could you check and merge PR?
Describe the PR
This simple PR logs outbound xfer bytes when log level is set to debug. It is useful to be able to dissect the full conversation and not only incoming packets.
While this may be too verbose, it is quite useful when things go south.
Additional context
This is really nice in combination with a simple USB dissector. I am currently using scapy to parse the logs. I may create a PR to scapy with the relevant USB layers and may post an example on how to use them in a fu...
It is helpful but too verbose, it could introduce other timing issues. Especially with bulk transfer like msc class. We should increase the log level to at least 3 for this info.
@Rocky04, I agree, a simple opt out based on a define sounds good. Something like this?
`diff --git a/src/device/usbd.c b/src/device/usbd.c
index 83217a869..4b30a7447 100644
--- a/src/device/usbd.c
+++ b/src/device/usbd.c
@@ -731,6 +731,7 @@ static bool process_control_request(uint8_t rhport, tusb_control_request_t const
tud_control_status(rhport, p_request);
break;
+#ifndef DISABLE_TUSB_TEST_MODE_SUPPORT
// Support for TEST_MODE
...
thank you, I enjoyed co-working with you on this PR as well.
Describe the PR
In some configurations local variable p_desc_parse_for_params is declared and never used resulting in warning that can be escalated to build error (for mynewt)
Now variable is surrounded with same preprocessor condition as function that uses it audiod_parse_for_AS_params()
Describe the PR
Retry flashing 3 times before giving up. S3 seems to have issue flashing randomly.
any news about this?
is there a fix? is it already available in v0.16.0?
regards
Max
HID report descriptors
N/A
There is a C standards conformance problem with the macros in class/hid/hid.h and negative 16-bit numbers. This makes it awkward to naturally specify negative numbers in HID report descriptors using the TinyUSB macros. These negative numbers often appear in the HID report descriptors of interfaces such as mice and joysticks. The existing templates in TinyUSB only use...
Hmm. USB_DRD_FS_BASE is not a defined symbol for me, but USB_DRD_FS is (and appears to be a register base address).
However, changing that as well as commenting out MX_ICACHE_Init() didn't help my situation. A breakpoint in USB_DRD_FS_IRQHandler is also never hit, and my computer doesn't react to plugging/unplugging the USB cable.
/* USER CODE END USB_DRD_FS_IRQn 0 /
//HAL_PCD_IRQHandler(&hpcd_USB_DRD_FS); <-- COMMENTED OUT
/ USER CODE BEGIN USB_DRD_FS_IRQn 1 /
tud_int_handler(0);
/ USER CODE END USB_DRD_FS_IRQn 1 */
}
main.c
make sure to call MX_USB_PCD_Init();
usb.c (see attached)
/* USER CODE BEGIN Header /
/...
Hmm.
USB_DRD_FS_BASEis not a defined symbol for me, butUSB_DRD_FSis (and appears to be a register base address).However, changing that as well as commenting out
MX_ICACHE_Init()didn't help my situation. A breakpoint inUSB_DRD_FS_IRQHandleris also never hit, and my computer doesn't react to plugging/unplugging the USB cable.
Contact me directly if you want me to walk you through getting this running
It was a PITA
That's an extremely generous offer. I am going to make an attempt to roll my own USB CDC implementation and eschew tinyusb; if that goes nowhere, I'll be in touch...
Yes sir, I do think that tinyusb will work for you and happy to help.
I know how frustrating this can be 🙂
M
From: Brian @.>
Sent: Wednesday, January 24, 2024 12:30 PM
To: hathach/tinyusb @.>
Cc: Michael Margolese @.>; Comment @.>
Subject: Re: [hathach/tinyusb] STM32H5 support (Issue #2203)
That's an extremely generous offer. I am going to make an attempt to roll my own USB CDC implementation and eschew tinyusb;...
I want to leave a big Plus here. What can be done to speed this Implementation up?
Describe the PR
minor update to video_capture example to make it easier to read. There should be no behavior changes.
Describe the PR
bump up to actions/setup-python@v5 to fix ci warnings
Node.js 16 actions are deprecated. Please update the following actions to use Node.js 20: actions/setup-python@v4. For more information see: https://github.blog/changelog/2023-09-22-github-actions-transitioning-from-node-16-to-node-20/.
Hi M, I'm not sure how to contact you directly. I followed the link from your profile and filled out the "contact us" form on that site. Is there a better way?
@.***
424-288-9585
From: Brian @.>
Sent: Friday, January 26, 2024 10:58 AM
To: hathach/tinyusb @.>
Cc: Michael Margolese @.>; Comment @.>
Subject: Re: [hathach/tinyusb] STM32H5 support (Issue #2203)
Hi M, I'm not sure how to contact you directly. I followed the link from your profile and filled out the "contact us" form on that site. Is there a better way?
—
Reply to this email directly, view it on GitH...
Describe the PR
UVC (as well as UAC) has a sophisticated configuration descriptor depending on user application, which make defining template macros rather difficult. I have update video_capture example to use custom struct to define uvc configuration descriptor. In my opinion, it make thing a bit clearer and easier to customize and troubleshoot descriptor typo/errors.
I also rename some of the video descritpor add several variant of struct/typedef with different number of trailing o...
Linux
PIC0 RP2040
Toggling between report and boot mode on mouse interface will block the keyboard interface on logitech wireless keyboard
Tested: K270/M185 and K220/M150
Connect one of these wireless logitech K270/M185 and K220/M150.
Press R to set report mode on mouse interface
Or B to set boot ...
Others
If an application uses tuh_cdc_mounted() to check whether a CDC device is mounted, it will be reported "true" before the process config is completed.
The application could then disrupt the process config or the application would not yet be able to work with the CDC device.
tuh_cdc_mount_cb() is correctly called in set_config_complete() after the process config has been completed.
the hid host ma...
As you said, I agree that defining descriptors using macros was very difficult. I think the method you suggested is very wonderful. Above all, I think it is good that the compiler’s type checking can be used, so that errors can be detected earlier.
Thank you for fixing tx_busy. It looks good for me. But I am not familiar with stm32f1, so I cannot comment on the changing related to it.
MacOS
Raspberry Pi Pico (RP2040)
examples/device/video_capture
(built from pico-examples for a Raspberry Pi Pico (probably works for other RP2040 targets as well))
Thanks for the tinyusb project! I stumbled across it a few years ago but I came back here because of Sebastian's GB Interceptor ("Capture or stream Game Boy gameplay footage via USB without modifying the Game Boy.", https://github.com/Staacks/...
indeed, fixed in following commit
As you said, I agree that defining descriptors using macros was very difficult. I think the method you suggested is very wonderful. Above all, I think it is good that the compiler’s type checking can be used, so that errors can be detected earlier.
thank you very much for your review, glad that makes sense. The macro template in example will be still kept there for referennce
can you revert the change in the f1 family.c since it break compile with other f1 that does not use UART.
Windows 10
RP2040 pico
usb host
rp2040 host usb and xip ssi problem the rp2040 work a host usb when attached the usb device the program stop after the replace this function (flash-bulk-read) by memcpy and re-try the system normal work note i-used this function to fast read data from flash memory and this function allocate into RAM
please help me to resolve this problem and the code is blew
`...
thank you, I made some changes to reset it when closing driver and rename to mounted.
whatt is PL2303_QUIRK_ENDPOINT_HACK hack for ?
please read getting started guide
oh, that's a good question...
I initially adopted it from Linux.
There seems to have been derivatives in the early days of the PL2303, where the EPs of one CDC port were distributed over two interfaces. This is no longer relevant for current derivatives. I removed these quirks.
And in pl2303_open() it is checked anyway whether the correct number of EPs is available.
I also removed PL2303_QUIRK_UART_STATE_IDX0 because it only affects the interrupt EP, which we don't use.
We should onl...
fix similar to Issue #2437 and PR #2438
Describe the PR
Modified vendor_device.c fifo mutex creation/configuration in the spirit of cdc_device.c.
This hopefully fixes #900.
Works on my machine (device STM32G474-DPOW1). ;)
I have tested the example app and it works with other combo devices and single keyboard and mouse connected over a hub. The only difference with logitech wireless devices is the wMaxPacketSize which is 20 for the mouse endpoint and 8 for the keyboard.
For the other tested devices wMaxPacketSize is less than or equal to 8 bytes.
The implementation is now finished from my side.
All tests with various PL2303s on my desk were successful.
Now it is ready for review and merge to master
Linux
ch34x_set_line_coding() handles user_data in wrong way:
if (user_data) {
user_data = result;
}
correct is:
if (user_data) {
*((xfer_result_t*) user_data) = result;
}
I'll create PR soon
No response
inline changenow tests of all CH34x on my desk are finished
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.
look great, thank you. The build failed due to unrelated change by ESP IDF
note we still need to call config complete to continue enumerating other device. Will do that as follow up later.
Thanks for the PR, but it only does simplify the code.
Since https://github.com/hathach/tinyusb/commit/876f49f6ad10ef2bca000602fe862889c3e0268f the locking mechanism is already introduced.
Windows 11
RP2040
V0.16.0
NB: works correctly in 0.15.0
Scenario 1:
Plug in a keyboard, tuh_hid_interface_protocol returns the correct value - 1
Then plug in a mouse, tuh_hid_interface_protocol returns the correct value - 2
Then plug in a gamepad, tuh_hid_interface_protocol returns the value for a mouse - 2 SHOULD BE 0
Scenario 2:
Plug in a gamepad, tuh_hid_interface_protocol returns the correct value - 0
Then p...
thank you @Yveaux !
I did add TinyUSB to the library as it should allow to use its hardware abstraction.
Using it as an external library now i run into exactly this issue bsp/* not been build as it is neither part of my project nor part of TinyUSB/src.
#include "bsp/board_api.h" // can not be found from within my project, therefor init fails
#include "tusb.h"
//------------- prototypes -------------//
static void cdc_task(void);
/*------------- MAIN -------------*/
i...
Linux
the callbacks are not handled correct
PR will follow soon
No response
ch34x_set_line_coding() forgets the requested complete_cb to be called after 2nd stage. so complete_cb is now stored in p_cdc->requested_complete_cbp_cdc->user_control_cb = complete_cb; in ch34x_set_data_format()Describe the PR
Currently vendor class manage data the same way as CDC class.
Many protocols using buck transfer are based on packets but not data stream like CDC.
In these cases a FIFO is not needed which adds overhead, also putting all packets in FIFO adds extra difficulty to separate them.
Additional context
I'm trying to make a CMSIS-DAP dongle.
upgraded driver:
- the two-stages
ch34x_set_line_coding()forgets the requestedcomplete_cbto be called after 2nd stage. socomplete_cbis now stored inp_cdc->requested_complete_cb
Have you tried passing the callback and verify that it is not invoked ?
- another bug: missing
p_cdc->user_control_cb = complete_cb;inch34x_set_data_format()
I remember don't assign calback for this intentionaly.
Describe the PR
thank you for another great PR for serial host. Unfortunate, Lunar New Year (aka TET) is super close and I don't have time to review/test out this PR in a few weeks or so. Meanwhile, would you mind fixing the CI build with other ports. It is probably suppress warnings since some ports has stricter warning flags than others. Thak you
is there any reason to move it here, otherwise please keep these header in there section
- the two-stages
ch34x_set_line_coding()forgets the requestedcomplete_cbto be called after 2nd stage. socomplete_cbis now stored inp_cdc->requested_complete_cbHave you tried passing the callback and verify that it is not invoked ?
- another bug: missing
p_cdc->user_control_cb = complete_cb;inch34x_set_data_format()I remember don't assign calback for this intentionaly.
Yes, and this is the starting point for all further issues.
`tuh_cdc_set_...
yes
#if CFG_TUH_CDC_PL2303
pl2303_t pl2303;
#endif
is added to cdch_interface_t. so #include "serial/pl2303.h" need to be before typedef struct ... cdch_interface_t.
And so I moved all includes to top of file for uniformity.
thank you for another great PR for serial host. Unfortunate, Lunar New Year (aka TET) is super close and I don't have time to review/test out this PR in a few weeks or so. Meanwhile, would you mind fixing the CI build with other ports. It is probably suppress warnings since some ports has stricter warning flags than others. Thak you
OK, thanks for your hint, I fixed the errors/warnings
thanks for confirmation, I remembmere specially write so that stage2 complete will invoke user callback. Let me double check that later, though I am not sure if I could do that before TET. Otherwise, please be patient and wait for a couple of weeks or more.
have a nice and relaxing time!
Linux
STM32U575
938cae818
I dont receive USB packets when they are the maximum packet size CFG_TUD_ENDPOINT0_SIZE immediately. I do receive when the host sends more bytes. (The host is a linux PC). So it's seem that the incoming ZLP isn't processed.
If I trigger handle_epout_irq manually, the packet is still not processed. So the packet is for some reason not provided yet by the hardware.
USB de...
Are you sure a zlp was sent ? Normally it has to be done explicitly.
The is a MTP library for the Teensy 3 & 4, but i hab no clue how to get this working with TinyUSB on the EPS32.
https://github.com/WMXZ-EU/MTP_t4
you are right, currently the ch34x_set_data_format() didn't store user callback. Though we don't need to add a new requested_complete_cb variable for this purpose. We only need to rename current ch34x_set_data_format() to an internal function (similar to ch34x_write_reg_baudrate()), and add user_control store for the public driver API
checkout review for request changes
must check if this is an IN transfer, otherwise, data contents is meaningless. It must be wrapped in #if CFG_TUD_LOG_LEVEL >= 3
not accepted, should be done by enumeration proccess when detecting getting device descriptor from newly attached device.
still haven't got time to test this out, will be off for a couple of week for TET holidays. Please be patient, thank you.
still haven't got time to test this out. I am off for TET holidays for a couple of weeks. Will try to review afterwards, thank you for your patient.
we can use existing CFG_TUD_VENDOR_RX_BUFSIZE when not defined or defined to 0 mean no buffered. https://github.com/hathach/tinyusb/blob/master/examples/device/webusb_serial/src/tusb_config.h#L104-L105
I am off for TET holidays for a couple of weeks. Will try to review afterwards, thank you for your patient.
we can use existing CFG_TUD_VENDOR_RX_BUFSIZE when not defined or defined to 0 mean no buffered.
That's true.
Me too I was back to China for holidays:)
keep this as LOG1, since failed is always print out with LOG LEVEL = 1
look great, thank you, only a few change request per review
please keep LOG1, consider as failed attempt
sorry still haven't got time to test this out. I am off for TET holidays for a couple of weeks. Will try to review afterwards, thank you for your patient.
tuh_get_port() is a confusing API name and its return in the PR is inconsistent as well. We can have an public API for hcd_devtree_get_info() with the name e.g tuh_devtree_get_info()
still haven't got time to test this out. I am off for TET holidays for a couple of weeks. Will try to review afterwards, thank you for your patient.
we can use existing CFG_TUD_VENDOR_RX_BUFSIZE when not defined or defined to 0 mean no buffered.
That's true.
Me too I was back to China for holidays:)
Have a great year of :dragon:
Well,
-> So it's seems that the the stm32u575 is not correctly initialised by tinyusb? Still need to take a deeper look
Hi, what is the status of this PR? what is missing for it to be approved?
The issue appears when CFG_TUD_CDC_RX_BUFSIZE CFG_TUD_CDC_TX_BUFSIZE and CFG_TUD_CDC_EP_BUFSIZE have a different definition than CFG_TUD_ENDPOINT0_SIZE.
It's still a mystery to me why that is the case
@hathach could you possibly review this PR as well?
I process 1,2MSPS (yes, I know, the ADC is a little overclocked) in the background.
This data is streamed via a ISO transfer to the PC.
Besides this, I have usbtmc for other purposes.
Additionally, there's a MSC interface for writing calibration data, update,...
PR #2392 fixes most problems I had so far, but.....
This works ok, but I get timeouts under linux from py-usbtmc during stress-testing.
Applying this change fixes at lea...
xfer->result in acm_process_config()TU_VERIFY(p_cdc->acm_capability.support_line_request); in acm_set_data_format() => moved it to common acm_set_line_coding()acm_set_line_coding()CFG_TUH_CDC in misc. example tusb_config.hPlease enable debug print which gives you much more information.
you are right, currently the ch34x_set_data_format() didn't store user callback. Though we don't need to add a new requested_complete_cb variable for this purpose. We only need to rename current ch34x_set_data_format() to an internal function (similar to
ch34x_write_reg_baudrate()), and add user_control store for the public driver API
OK, done
Made the requested changes. Also improved a bit on the previous solution.
Thank you for being so patient with this minuscule PR. it is helping me learn more about the project!
it's already done in tuh_control_xfer()
This issue might look trivial but It looks like an issue with the hardware controller. After toggling the report protocol, the keyboard endpoint get blocked. The host sends request to the keyboard endpoint and the keyboard is replying the IN request but the host is not sending the ACK and restart the IN transfer without firing any interrupt.
This is an attempt to add support for NXP Kinetis K28FA. Effort is mostly based on the existing ports for kinetis_k32l2, mimxrt1170_evkb and the frdmk28fa_dev_composite_cdc_vcom_cdc_vcom_bm example in NXP MCUXpresso.
Current state of the port
Build OK:
tinyusb$ make -C examples/device/cdc_dual_ports/ BOARD=frdm_k28fa15 LOG=2 all
...
CREATE _build/frdm_k28fa15/cdc_dual_ports.hex
text data bss dec hex filename
26436 152 10260 36848 8f...
Something like this? I'm in doubt where everything should land...
I'm currently making extensive changes to the CDC host to add new support for PL2303, expand FTDI and CP210x, and simplify and reduce the code size.
It might make more sense to review just one PR with all the changes rather than several smaller PRs.
If you agree then I'll withdraw this PR and create a "big" PR soon.
I will also carry out a complete test of all devices.
I have all of them (ACM, FTDI, CP210x, CH34x, PL2303) as real HW in various versions (RS232/TTL, different chip versions ...
I'm currently making extensive changes to the CDC host to add new support for PL2303, expand FTDI and CP210x, and simplify and reduce the code size.
It might make more sense to review just one PR with all the changes rather than several smaller PRs.
If you agree then I'll withdraw this PR and create a "big" PR soon.
I will also carry out a complete test of all devices.
I have all of them (ACM, FTDI, CP210x, CH34x, PL2303) as real HW in various versions (RS232/TTL, different chip versions ...
I'm currently making extensive changes to the CDC host to add new support for PL2303, expand FTDI and CP210x, and simplify and reduce the code size.
It might make more sense to review just one PR with all the changes rather than several smaller PRs.
If you agree then I'll withdraw this PR and create a "big" PR soon.
I will also carry out a complete test of all devices.
I have all of them (ACM, FTDI, CP210x, CH34x, PL2303) as real HW in various versions (RS232/TTL, different chip versions ...
I'm currently making extensive changes to the CDC host to add new support for PL2303, expand FTDI and CP210x, and simplify and reduce the code size.
It might make more sense to review just one PR with all the changes rather than several smaller PRs.
If you agree then I'll withdraw this PR and create a "big" PR soon.
I will also carry out a complete test of all devices.
I have all of them (ACM, FTDI, CP210x, CH34x, PL2303) as real HW in various versions (RS232/TTL, different chip versions ...
I'm currently making extensive changes to the CDC host to add new support for PL2303, expand FTDI and CP210x, and simplify and reduce the code size.
It might make more sense to review just one PR with all the changes rather than several smaller PRs.
If you agree then I'll withdraw this PR and create a "big" PR soon.
I will also carry out a complete test of all devices.
I have all of them (ACM, FTDI, CP210x, CH34x, PL2303) as real HW in various versions (RS232/TTL, different chip versions ...
Describe the PR
NRF5x USB controller can detect ISO OUT CRC errors. In such case USBEVENT is signaled with EVENTCAUSE_ISOOUTCRC set. Even if controller detects corrupted ISO OUT packet it allows to data transfer from endpoint to RAM however packet is corrupted and code could just as well drop packet altogether.
With current implementation incoming ISO OUT packets were put in FIFO and exact information how much data already in FIFO is correct was hard to keep track of.
If was observed...
Linux
frdmk32l2a4
examples/device/cdc_msc
The clock config file used is wrong. I'm not sure how it ever worked, but perhaps the defaults used to be different.
The board makefile here: https://github.com/hathach/tinyusb/blob/master/hw/bsp/kinetis_k32l2/boards/frdm_k32l2a4s/board.mk#L11 is including the "project_template" clock_config.c file for the device "K32L2A4S" which is here: https://github.com/hathach/mcux-sdk/blo...
diff --git a/hw/bsp/kinetis_k32l2/boards/frdm_k32l2a4s/board.mk b/hw/bsp/kinetis_k32l2/boards/frdm_k32l2a4s/board.mk
index f69700139..851968794 100644
--- a/hw/bsp/kinetis_k32l2/boards/frdm_k32l2a4s/board.mk
+++ b/hw/bsp/kinetis_k32l2/boards/frdm_k32l2a4s/board.mk
@@ -8,8 +8,8 @@ CFLAGS += -Wno-error=unused-parameter -Wno-error=redundant-decls -Wno-error=cast
# All source paths should be relative to the top level.
LD_FILE = $(MCU_DIR)/gcc/K32L2A41xxxxA_flash.ld
-SRC_C += \
-...
TinyUSB stack ported to MCX A and MXC N freedom boards.
Notes
MCX A and MCX N families created under hw/bsp folder. Due to differing compiler options required by different versions of ARM Cortex M-33 for MCX A and MCX N, they were not grouped together in the same family.
Build code for make and cmake tools added under example/build_system to support the ARM Cortex M-33 core with no DSP and no FPU.
Since the NXP SDK repository is not up to date yet, the tools/get_dep...
Some extra info.
This is what I see with the working NXP example:
With my tinyusb port I see nothing in the wireshark.
Special thanks to Prodrive Technologies for giving me time to create this and push it back to the community.
Well, here I am again. It's been a while; the work to try to get this working was shelved for a while. Now it's back on my plate.
What I've done most recently is do a git reset --hard and git pull on my checkout of tinyusb. That seems to have brought in a lot of changes that look like they're meant to provide STM32H5xx support.
I've gone through some example code that @sckid1108 very kindly provided, looking for differences between his and mine, and reconciled as many as I could ...
Hi, adding a few details here since this is impacting me as well.
Computer: Windows 11 version 22H2 build 22621.3007
Microcontroller:
Like others, a change from bcdUSB = 0x0200 to bcdUSB = 0x0210 makes the device no lo...
Linux
../tinyusb/src/common/tusb_fifo.c: In function '_ff_push_n':
../tinyusb/src/common/tusb_fifo.c:162:3: warning: switch missing default case [-Wswitch-default]
162 | switch (copy_mode)
| ^~~~~~
No response
Looks like the dcd_reg->ENDPTSETUPSTAT is missed in dcd_int_handler because int_status & INTR_USB is not set at the same time.
Set Up
- PC OS
Windows 10- Board*
Samg55- Firmware
4 Port Hub with keyboard attachedDescribe The Bug If I attach the Hub and the keyboard the enumeration stops at GetDeviceDescriptor To Reproduce
tusb_init(); // initialize tinyusb stack while (true) { tuh_task(); }Steps to reproduce the behavior:
- plug in the hub
- plug in the keyboard
- See error stop on GetPortStatus
...
I am adding the #define CFG_TUSB_DEBUG 3 logging for the both scenarios above (I hadn't realized I could enable this before).
bcdUSB = 0x0200 and bcdUSB = 0x0210This image is the first of 4 sequences of the same pattern.
It is showing that in the bcdUSB = 0x0210 case, the BUS RESET and USBD Bus Reset : Full Speed don't occur, also that the USBD Setup Received bytes change from 00 05 31 ... to 00 05 25 ..., but I do...
Hi, great work,
very nice feedback method improvement on Tinyusb class Audio !
I Have implemented the feedback method FIFO_COUNTER (stereo 16 bit, 48KHz) on a my RP2040 hardware with I2S DAC with success .. but ...
I observe a good audio USB reproduction on Windows but the system crashes on MAC computer...???
If, instead, I remove only the feedback EP, the system It's starting to work on MAC too ! But obviously not sync ...
Could this be due to the fact that macOS does not accept this ...
Hello, I think I have the same problem. Have you found any leads since then?
Hi, great work, very nice feedback method improvement on Tinyusb class Audio ! I Have implemented the feedback method FIFO_COUNTER (stereo 16 bit, 48KHz) on a my RP2040 hardware with I2S DAC with success .. but ... I observe a good audio USB reproduction on Windows but the system crashes on MAC computer...??? If, instead, I remove only the feedback EP, the system It's starting to work on MAC too ! But obviously not sync ...
Could this be due to the fact that macOS does not accept thi...
I observe a good audio USB reproduction on Windows but the system crashes on MAC computer...??? If, instead, I remove only the feedback EP, the system It's starting to work on MAC too ! But obviously not sync ...
How did you get it working on Windows?
I have interface 1 containing the data endpoint OUT and the feedback endpoint IN. Then I have interface 2 containing only the data endpoint IN.
On Linux I can see it working (I still have to validate the absence of glitches), and with wir...
I recommend you the section "Feedback for Asynchronous Output Streams" in https://developer.apple.com/library/archive/technotes/tn2274/_index.html
Do you know whether Windows also has such behavior?
I would also recommend you to test to add "
TUSB_ISO_EP_ATT_IMPLICIT_FB" in yourStandard AS Isochronous Audio Data Endpoint Descriptor
I have interface 1 containing the data endpoint 1 OUT and the feedback endpoint 1 IN. Then I have interface 2 containing only the data endpoint 2...
If this interrupt ever hits it will result in an infinite interrupt loop as it is never cleared.
Hi @mastupristi, can you show me your tusb_desc.c and tusb_desc.h if you have them ?
I didn't use this fifo counting feedback branch yet, so I'm not sure if my suggestions could work in this case.
After some hindsight, my bad, I think changing any endpoint to implicit feedback is a non-sense in this situation, because the whole branch is about a feedback endpoint which is necessarily explicit.
In the example [uac2_speaker_fb](https://github.com/HiFiPhile/tinyusb/tree/rx_fb/exam...
Hi @mastupristi, can you show me your
tusb_desc.candtusb_desc.hif you have them ? I didn't use this fifo counting feedback branch yet, so I'm not sure if my suggestions could work in this case.
I am also not using the counting fifo method. I tried the rx_fb branch but in the end we went back to the main repo branch. We calculate the feedback "by hand," and it proves very reliable even in tests where we vary the clock of our peripheral. We see that the host "chases" our clock suf...
Describe the PR
RT-Thread has modified there message queue api on version 5.0.0, which may unexpectly cause function tud_task_ext return without processing usb message.
Additional context
See PR at RT-Thread
https://github.com/RT-Thread/rt-thread/pull/7709
Describe the PR
hw_endpoint_lock_update is unimplemented for the rp2040 port. This PR takes a stab at implementing it. Without it, if the USB port is disconnected, say with tud_disconnect, a race condition can happen where a transfer is in progress and the USB IRQ can fire, calling reset_non_control_endpoints and leaving the ongoing transfer in a bad state, as it tries to access endpoint data structures that are now zero'd.
While debugging that main issue, I also found some case...
Hi @mastupristi
Yes could you send me your usb_descriptors.[ch], to look if there is something strange x)
Maybe you could create a GitHub issue and ping me, it would be more convenient than trying to fix it here
And yes, your screenshot is totally on point, I was just not sure if you used this branch or not
Hi @Protoxy22
Maybe you could create a GitHub issue and ping me, it would be more convenient than trying to fix it here
I started a discussion here: https://github.com/hathach/tinyusb/discussions/2475
@nikitos1550 : I started from the HS driver and it was not present there at that time.
I've been using the FS port for a while now and it works ok if not perfect.
(sorry for the late reply)
Linux
Raspberry Pi Pico
#include "Adafruit_TinyUSB.h"
void setup()
{
pinMode(LED_BUILTIN, OUTPUT);
Serial.begin(115200);
Serial1.begin(115200); //for debug
}
void loop()
{
digitalWrite(LED_BUILTIN, tud_connected());
}
tud_connected() and tud_mounted() correctly return FALSE before USB is connected, and TRUE when connected. However, they continue to return TRUE indefinitely after USB is no long...
H563 is already supported, tested with stock example on H563 Nucleo. If it does not work for you specify your H5 variant also which board you are tested with.
can you make an PR to update my mcux-sdk instead ? or we can wait until nxp repo is updated. The idea is the driver should either pointed to vendor's or my fork only.
please have this as
| MCX | A15, N9 |
Thank you very much for your PR. It looks great, though there is some change request below:
MCX A and MCX N families created under hw/bsp folder. Due to differing compiler options required by different versions of ARM Cortex M-33 for MCX A and MCX N, they were not grouped together in the same family.
besides the DSP/FPU option, is there any other difference, we can solve this by either using the MCU_VARIANT check in family.mk/cmake or just set the correct CPU_CORE in the board.mk/cm...
Plesae remove this file, and use the existing mcx.h, we can sort out the mcxa vs mcxn there using existing macros.
Describe the PR
Follow suggestion from https://github.com/hathach/tinyusb/discussions/2318
Describe the PR
Fix #2464 based on suggestion (option C).
I made an PR based on option C, though I don't have the board to test with, please test it out to see if that works now. Thank you
Confirmed that it works. I cherry-picked my WIP to enable host mode and it works too.
Confirmed that it works. I cherry-picked my WIP to enable host mode and it works too.
thank you, it is merged now :)
I've got another tree with frdmk-64 support as well. I'll compare the two and comment.
I don't think this should be here. You're not required to use the IRC48 for clocking USB, it's an option, and certainly not required. I think this should be handled externally, via board/user clock setups
why did you need to specify these explicitly?
Why did you need the freertosconfig.h file? That seems unnecessary to have another copy of it? (and freertos demos work fine for me without it)
I'm still clearing our work with internal management, so it's not (very) publically shared yet unfortunately.
these don't look correct. (shouldn't hurt but not... correct ...)
Thanks, copy paste error, fixed.
Hi, sorry for the late response. I added the opt-out to exclude the code if the test mode is not wanted.
Sadly no-one seems to have reviewed the code so far. There aren't that many people who maintain this repro.
I did a quick test with CH32V30X chips, it seems to work also there (very minor changes needed because i'm not using wch SDK)
Good job!
How about use uint32_t type instead of pointer?
RV64 architectures fail with native pointer at this place...
yeah sure, would you mind making an PR for this change
Describe the PR
Fixes may be used uninitialized compiler warning for variable interval_ms when building at optimization level -Og. Compiler is GCC 13.2.
Additional context
../../lib/tinyusb/src/class/video/video_device.c: In function '_negotiate_streaming_parameters':
../../lib/tinyusb/src/class/video/video_device.c:578:36: error: 'interval_ms' may be used uninitialized [-Werror=maybe-uninitialized]
578 | payload_size = (frame_size + interval_ms - 1) / in...
Windows 10
STM32F4
custom firmware
Audio Mic works with the base example where the MCU does nothing but calling tud_task. However, any real use case involves other tasks processed by the MCU. Any processing that takes too long without calling tud_task (haven't checked exactly, but seems close to a millisecond or a few hundred us), and the received audio data on the computer is corrupted (zeros in place of the real audio da...
There are already many discussions regarding real time data streaming, basically 2 options:
Delay().tud_task() inside USB ISR, eg. OTG_FS_IRQHandler().Thank you a lot for your feedback.
I already made the pull request for your mcux-sdk fork.
When we have the mcux-sdk updated I'm going to push the corrections.
@Ryzee119 I am back from TET holidays, which compiler you are using. If it is arm clang, I could give it a try (was planning to support it anwyay).
yeah, it should be ci_hs, try to compile with LOG=2 and checkout its output with either UART or segger rtt (LOGGER=RTT)
yeah, it should be ci_hs, try to compile with
LOG=2and checkout its output with either UART or segger rtt (LOGGER=RTT)
If I didn't totally misunderstand, this is what I've already done? Please check the PR description. Additionally, I have observed the dcd_int_handler behavior in debugger and saw ENDPTSETUPSTAT going unhandled in the current logic.
Describe the PR
slightly change cdc_msc_freertos example
Had some time again recently to check this issue out...
The problem is that when a TinyUSB device is used on an active USB hub it don't react properly when the host is either shutdown or disconnected from the hub. In that case the hub will may provide a single-ended zero signal on both data wires resulting in a continuous reset state for the device while the device is still being powered.
If the device was in the suspended state before the tud_resume_cb was never invoked while `tud_...
This PR is the kick-off of the series of single commits, which should result in the following improvements:
I think, it'...
I think it is copied from other bsp setting, I may or may not required, I forgot as well.
Why did you need the freertosconfig.h file? That seems unnecessary to have another copy of it? (and freertos demos work fine for me without it)
I'm still clearing our work with internal management, so it's not (very) publically shared yet unfortunately.
It is part of my new approach, previously there is 1 freertos (per example) for all ports. However, that makes it difficult to compile with IAR since freeRTOSConfig.h is included by IAR assembler which is very primitive and cannot ...
thank you, I have tested this with my frdm k64f board, working well. The save/restore crystal-less configuration is required, otherwise setting will be reset. There is no harm to restore these value when not using crystal-less mode
@IngHK thank you, though don't worry too much about the number of commits etc, just make it convenient for you. I don't always have time to review things (pending PRs is already long enough), but small change is indeed easier to review. So just group thing together as long as you think that make sense. The current PR only update comment, do you have anything to push more or you want to merge this as it is.
well, my only other concern is that not all the kinetis parts have those crystalless config registers, so we're going to be writing into registers that don't always exist.
@IngHK thank you, though don't worry too much about the number of commits etc, just make it convenient for you. I don't always have time to review things (pending PRs is already long enough), but small change is indeed easier to review. So just group thing together as long as you think that make sense. The current PR only update comment, do you have anything to push more or you want to merge this as it is.
Yes, I know, the first commit is pretty small, only to warm up ;-)
The next commi...
The last commit improves the TU_LOGs.
It standardizes the logs with a uniform beginning "[:dadr:itf_num] CHCh drivername ...".
And it moves the logs from the driver to the common cdc section.
Here an example output:
I think these are commits that need to be reviewed first.
After the review and, if necessary, my follow-up work, I will push further commits
I will pull out to test with my kl25z board, I think it shouldn't have any effect. In my experience, these registers exist anyway, it is just readonly. If it is an issue, We can actually check the IRC_EN bit before restoring value, but I guess it is not really needed.
PS: it cause out-of-memory issue on KL25Z, PR is on the way to fix this :)
Describe the PR
only save/restore CLK_RECOVER_IRC_EN/CTRL if FSL_FEATURE_USB_KHCI_IRC…48M_MODULE_CLOCK_ENABLED is defined to 1
@IngHK I appreciated your effor to break it out, but please push everything you think work best. Otherwise this make take several months to complete this whole process. I would like to merge portion of code once it is reviewed, and I may only have time to review this 1 or 2 times a month or so. Last time, I could focus on the PR since I need to get ch34x driver running for another paid works.
yeah, it should be ci_hs, try to compile with
LOG=2and checkout its output with either UART or segger rtt (LOGGER=RTT)If I didn't totally misunderstand, this is what I've already done? Please check the PR description. Additionally, I have observed the
dcd_int_handlerbehavior in debugger and sawENDPTSETUPSTATgoing unhandled in the current logic.
sorry my bad, look like it could be an clock/setup issue, each MCU will have slightly different clock setup. Unfortunately I ...
@hathach OK, no problem, we'll do it the way that suits you best.
Now I've pushed everything.
I'm currently writing a small test suite to do the tests with hardware.
The intention here was to move the driver-specific code parts into the driver sections so that the general CDC section does not contain any driver code (as possible).
In addition, cdch_internal_control_complete() had become quite bloated and confusing.
The intention here was to move the driver-specific code parts into the driver sections so that the general CDC section does not contain any driver code (as possible).
In addition, cdch_internal_control_complete() had become quite bloated and confusing.
The intention here was to simplify the parameter passing of the Control Endpoint API calls to the driver functions.
p_cdc->requested_line_coding was already available for FTDI, CP210X and CH34X anyway.
And it makes the internal control complete functions safe and easy.
the same as previous commit, but now with the requested line state
Since the central flow code of tuh_cdc_set_control_line_state(), tuh_cdc_set_baudrate(), tuh_cdc_set_data_format() and tuh_cdc_set_line_coding() is identical and very tricky, it was outsourced to the common subfunction set_function_call(), which calls the regarding driver's function.
Here you see, why I moved the requested line coding and line state into p_cdc->requested..., because it also simplifies the parameter transfer from Control Endpoint API to Driver API independent of four differen...
now the enumeration will continue, even if a process config fails
now the enumeration will continue, even if a process config fails
this was missed in acm_set_data_format().
moved them to common called acm_set_line_coding()
the same as previous commit, but now with the requested line state
Now we have a clear separation between the Control Request and Driver API sections
now it's calling only Driver API functions, which was one reason for the bug
now it's calling only Driver API functions, which was one reason for the bug
now the complete_cb ist stored to be called in ch34x_set_line_coding_stage1_complete() after stage 2.
This was 2nd reason for the bug
#if is not correct.
the value 0 for CFG_TUH_CDC_LINE_CONTROL_ON_ENUM is also valid to reset RTS and DTR (after reset of the host-CPU without re-power-up or re-plug of the USB CDC device).
Only if CFG_TUH_CDC_LINE_CONTROL_ON_ENUM is undefined, then this step should be skipped.
Here is the central 2-stage-sequence of setting baudrate and data format outsourced from CH34x into common used set_line_coding_sequence() and set_line_coding_stage1_complete().
It will be also used by FTDI's and and CP210x's set line coding functions (see next commits), because they also requires this sequence.
I always see the IAR build fail, but with no relation to CDCh. Is it OK?
../tinyusb/src/tusb.c: In function 'tu_print_mem':
../tinyusb/src/tusb.c:480:16: warning: conversion from 'int' to 'char' may change value [-Wconversion]
480 | format[2] += 2*size;
| ^
Linux
ESP32-S3-DevKit-1
n/a
I'm trying to implement a FIDO2 USB Device. Using espressif-tinyUsb within Arudino IDE. Adapted standard CustomHIDDevice - just exchanged the report_descriptior with a FIDO2 compliant one - see attachment.
fido.txt
Communication is comming in using requestID 255 - which is not "visible" within the scatch and does not match the spec...
By the way. I am seeing the same behavior on NXP MIMXRT1160-EVK secondary processor (M4). The primary core or M7 is working as expected. Just in case you have access to these boards more easily.
RP2040 device controller does not seem to clear pending transactions configured in EP0 buffer controls when the host aborts a control transfer. This causes assertion failures, including when a buffer AVAILABLE flag set for a previous transfer causes an unexpected transaction completion.
Describe the PR
Fix assertion failures or panics in the RP2040 DCD when handling aborted control transfers.
Additional context
See adafruit/circuitpython#8824 for analysis and traces.
It's p...
The ep_int_in is already used for responding to USB488 READ_STATUS_BYTE requests, but that EP is defined for the entire USBTMC class. This extends the functionality to let callers send notifications and receive ACKs.
Windows 10
stm32h743ii
freertos 10.4
tinyusb-0.16.0
cannot execute
cannot execute
USBD init on controller 0
sizeof(usbd_device_t) = 55
sizeof(tu_fifo_t) = 20
sizeof(tu_edpt_stream_t) = 36
TMC init
usbtmcd_init_cb 249: ASSERT FAILED
guid, gsnpsid, ghwcfg1, ghwcfg2, ghwcfg3, ghwcfg4
0x00002300, 0x4F54330A, 0x00000000, 0x229FE190, 0x03B8...
I'll have to revise this patch, both to clear the ABORT_DONE bits, and to only use ABORT on hardware B2 or later. See adafruit/circuitpython#8824 for details.
Fixed some bugs...
The later is related when such a device is connected to an active USB hub while that gets disconnected from the host. In that case the hub may continuously send a USB reset signal. Because it can take a long time until the reset state is...
Back from holiday...
I would add TUSB_ISO_EP_ATT_EXPLICIT_FB on the data endpoints, just to be sure that all OS are suggested to use the available feedback endpoint @HiFiPhile ?
No it's not how it works...
I observe a good audio USB reproduction on Windows but the system crashes on MAC computer...???
What do you mean crash, does the kernel panic or having popping sound or something else ?
You can try to change https://github.com/hathach/tinyusb/blob/2720392a154dac5ff4529fbcc16c0a0718c9c8af/src/class/audio/audio_device.h#L196
/...
the "maybe fixed" is working for you david vogman ?
here is a bug.
will be fixed in a subsequent commit.
Hello Thach!
I already made the changes
This wasn't tested at all
Adds support for the SparkFun SAMD21 Mini Breakout
It has different TX/RX pins for serial, so I had to do some preprocessor shenanigans in family.c.
Let me know if there's a better way to do this and I will change it - I'm quite new to TinyUSB.
thank you very much, I wil review this whenever I could.
@Kozova1
I rewrite the code as you done for vendor_host.c, vendor_host.h and usbh.c
i put #define CFG_TUH_VENDOR 1 in the configuration file, i tested with the host_hid_to_device_cdc by changing everything from host hid to host vendor.
i tried to print dev_addr and nothing is displayed. Can you help me to fix it ?
@jmark1m did you manage to get the vendor specific host to work?
I also want to install bidirectional communication. Do you have an example of implementation or can you help me do it?
What needs to be done in order to migrate/upgrade this? I want to communicate with a ft232r with the rp2040's USB. I want to try to contribute, but I have no idea what the needed changes are.
See #2488.
Any kind of feedback, review and test is welcome.
I guess I did manage to get usb host to work just using the tinyusb submodule that comes with the pico 2040 sdk.
For my project it was known what devices were going to be plugged in to it so I assigned them fixed end points and didn't go through all of the things a host should do to assign endpoints.
But eventually I just sent data from my host to the device with this simple function.
Good luck.
bool hid_send( board::host_command_t command )
{
tuh_xfer_t xfer =
{
...
@jmark1m thanks for your reply.
Can i see the full code of your project ?
Describe the PR
Host Vendor Class API
pico w, esp32 s3
Hello Everyone,
I am currently working on a project where I use a USB cable for communication between my stm32 in vendor-specific device mode and a PC software with libusb, and I want to replace it with a connection of my board to the USB of the pico w or the esp32 s3 to communicate through WiFi.
For this, I wanted to know when will we have the complete h...
I think you can use the raw API to do it yourself: https://github.com/hathach/tinyusb/blob/master/src/host/usbh.h#L174
Vendor-specific modes will vary by vendor and don't make much sense to add to TinyUSB.
Linux
N/A
examples/device/uac2_headset/src/main.c
https://github.com/hathach/tinyusb/blob/2720392a154dac5ff4529fbcc16c0a0718c9c8af/examples/device/uac2_headset/src/main.c#L234
The condition UAC2_ENTITY_SPK_FEATURE_UNIT looks unusual (it is always true). Is this intentional?
N/A
N/A
No response
Hi, I'm really sorry to revive this issue but I tought it might be a good place to figure out what the current status on a generic SOF callback is? Aplogies if I missed anyhting, but I couldn't relaly find any information on this.
@tannewt thanks for your reply.
Do you have any tips or tutorials and also documentation to build it by myself ?
Hi,
I continued working with a Full-Speed USB audio system RP2040 48KHz 16 bit by using feedback explicit endpoint.
(TinyUSB with FIFO counter feedback mechanism).
I've done other experiments and I get the impression that the usbd_edpt_xfer() function on low-level stack doesn't work well when we try to send 3 bytes.
These are my two scenarios:
MAC:
So, could the problem be on the low level of the Tinyusb stack when we try to send 3 bytes feedback via usbd_edpt_xfer() to Host ???
No it can't be, you also tested 3 bytes works on MAC.
If I use, instead, the same code of MAC (as above MaxPacketBytes = 3 in the descriptor) unfortunately the system stops working because the Audio class it is not enumerate on WIndows and I no longer see the card ... ???
It's true.
I tested the pico-playground usb_sound_card project (Pico boar...
we can use existing CFG_TUD_VENDOR_RX_BUFSIZE when not defined or defined to 0 mean no buffered.
@hathach Done
Hi,
thank you for reply and sorry if I try to clarify better:
No it can't be, you also tested 3 bytes works on MAC.
No, my previous comment is precisely because I tested that the 3 bytes don't seem to work (see my pont 1, 2 about MAC):
Describe the PR
abort all pending transfer when SET_CONFIGURATION is complete
tu_edpt_release() is lighter version
move _parse_configuration_descriptor() from pre to post SET_CONNFIGURATION
I'm back from holidays, and this asserts (vApplicationStackOverflowHook 43: ASSERT FAILED ) when a hub is plugged in, with the examples/host/cdc_msc_hid_freertos example.
My local version (didn't get to a PR) works fine. I can't see what the difference would be (yet) but I'm obviously goin to have to find out :) Did this example work for you at all?
Related to the FreeRTOSConfig files, the newly added file is not even used at present. At least in the host/cdc_msc_hid_freertos. ...
You also removed the pinmuxing, are you sure this actually works with uarts after those changes?
@Marcus2060
The system doesn't work if I try to send 3 Bytes (10.14) via usbd_edpt_xfer() but with MaxPacketBytes=4 (MaxPacketBytes means Max number of bytes transfer on the endpoint ??...)
Sorry I've some problem understanding, you mean 3 Bytes && MaxPacketBytes=4 doesn't work ? How about MaxPacketBytes=3 ?
Sorry I've some problem understanding, you mean 3 Bytes && MaxPacketBytes=4 doesn't work ? How about 3 Bytes && MaxPacketBytes=3 ?
Below 4 different tests on MAC using 10.14 format:
Windows 10
custom STM32F4
Custom
Hello,
When I add feedback endpoint to my USB microphone application the device enumerates but hangs immediately after.
This is what I did :
When (3 Bytes sent) && (MaxPacketBytes=3) -> No Sync, some clicks.
I agree it seems strange but I don't see any issue in TUSB side (maybe something wrong in RP2040 porting ?), could you use Wireshark USB capture to see what happened ?
What are the steps holding this back from being merged?
thank you I am able to reproduce the issue mentioned in https://github.com/adafruit/circuitpython/issues/8824 with stock cdc_dual_ports example using my intel macbook (os 12.6) using tio quit. I will investigate more and review suggested fix by this PR.
as expected, macos send 2 setup consecutive probably due to late response from rp2040. Per USB specs, host can send up to 3 setup packet consecutively, for this tinyusb should drop the previous setup request and process this one instead. (note the 2 setup packets are indentical).
Windows 10
STM32F072 Custom Board
STM32CubeIDE configured following #633 with tusb_config.h to use RHPORT 0 and USB Full Speed instead of High speed.
Main firmware:
examples/device/midi_test
usb_descriptors.c identical to example, other than changing product name.
I'm new to USB and trying to get my custom STM32F072 MIDI controller recognized by windows. I've followed the steps outlined in #633 for my needs and the...
Standard timeout for control requests with no data stage is 50ms. The second SETUP arrives within the same millisecond as the ACK for the first. This is more likely the host application (probably actually the kernel serial driver) cancelling the control request IRP before completion.
I don't think we can depend on the second control request being identical to the first, in that case, so it's safer to process both. Skipping the data or status stages when the interrupt flags show that a SETU...
USB 2.0 §5.5.5
If a Setup transaction is received by an endpoint before a previously initiated control transfer is completed, the device must abort the current transfer/operation and handle the new control Setup transaction. A Setup transaction should not normally be sent before the completion of a previous control transfer. However, if a transfer is aborted, for example, due to errors on the bus, the host can send the next Setup transaction prematurely from the endpoint’s perspective.
Class UVC
esp32sx
I want to define a UVC device with two VS (Video Streaming) interfaces, capable of simultaneously transmitting two video streams. However, the current class UVC driver does not support installing all VS VC (Video Control) interfaces.
I've identified two main issues and made modifications to the source code, enabling the simultaneous opening of two VS (Video Streaming) interfac...
Hi,
I agree it seems strange but I don't see any issue in TUSB side (maybe something wrong in RP2040 porting ?), could you use Wireshark USB capture to see what happened ?
Yes, thank you for your suggestion, I tried with Wiresharc and my board connected to Windows: The messages LOG shows that 3 bytes messages of feedback are sent from the TinyUsb stack to Host correctly on size and value !
So the problem seems to be a different behavior of TinyUsb Audio Class 2.0 between Win...
I have verified that there is no problem with this PR.
Hello, I verified on the RA series MCU that when the msc and cdc devices are turned on, this modification will cause a usb enumeration time of about 20 seconds.
Those were previously defined in spresense-exported-sdk, but now have been removed.
should we wrap these with #ifndef so that it can work with both sdk 3.2.0 and previous sdk version ?
dcd_stm32_fsdev.c: Fix a bug seen with stm32h5xxx when the driver is compiled with CubeIde O1/O2/O3
patch fixes a bug discovered when I build my application for the speed. The new timing introduces a bug in the function pcd_get_ep_rx_cnt().
The function doesn't return the correct value.
After discussion with my colleagues, they told me that this issue is fixed with a workaround.
This workaround is ported from stm32h5xx_hal_pcd.h : PCD_GET_EP_RX_CNT (ST HAL for H5)
Issue observed on...
Describe the PR
Has anyone got this working?
I've attempted to reconcile these changes with the version of tinyusb used by Pico SDK, but at best nothing happens and at worst I can reliably crash my board. This happens when I attempt to adjust the volume from the host after calling tud_audio_int_ctr_n_write .
There's an awful work in progress mess here:
This doesn't show my futile modifications ...
I came across the linked PR while searching for a means to synchronise device control changes (volume and mute in particular) to the host. I'd like to register my interest in this feature.
superb! Thank you very much for investigation and fixing the issue. I have also made some tweaks to the PR
I guess we can conclude that macos driver does not send BREAK request.
~You also removed the pinmuxing, are you sure this actually works with uarts after those changes?~ Well, the uart still works, with LOGGER=uart, so I guess mcux is doing pinmuxing automatically....
pin muxing is done by boards/pin_mux.c which I use mcupinconfig to generate.
Related to the FreeRTOSConfig files, the newly added file is not even used at present. At least in the host/cdc_msc_hid_freertos. I added #error calls, and it's still using the standard one from the example. (ho...
Others
Raspberry Pi Pico
examples/host/msc_file_explorer
A customer sent us a product they designed based on our RP2040. They also supplied a usb hub which they reported caused problems with hid device enumeration when the hub was connected to their product. Debugging the problem on one of our Pico boards with our SDK, I can see that the tip of tinyUSB today exhibits the problem which is that there is a panic in tinyUSB wh...
A little bit of background. The problem came to my notice in Olimex's reason for creating a USB hub board where they gave some detail, including:
Unfortunately, in most cases, these cheap USB hubs, like the one we have on the web and many others, simply refuse to work. Out of the 10 USB hubs I bought to ...
By the way. I am seeing the same behavior on NXP MIMXRT1160-EVK secondary processor (M4). The primary core or M7 is working as expected. Just in case you have access to these boards more easily.
Oh, I don't have rt1160 but got 1170. Let me try to see if I could make a quick switch from m7 to m4 to compile with. However, they can be two different issues with different clock/pin configuration since these MCUs are totally different.
I can take a look later, but there are too much pending changes in UAC class not merged yet...
Thanks for your PR, but it seems there are some unwanted commits included, could you make a rebase ?
By the way. I am seeing the same behavior on NXP MIMXRT1160-EVK secondary processor (M4). The primary core or M7 is working as expected. Just in case you have access to these boards more easily.
Oh, I don't have rt1160 but got 1170. Let me try to see if I could make a quick switch from m7 to m4 to compile with. However, they can be two different issues with different clock/pin configuration since these MCUs are totally different.
1170 should be fine. As a background, I did the M...
I can take a look later
Thank you!
I can take a look later, but there are too much pending changes in UAC class not merged yet...
😬 I guess I'm going to have some fixes to do in future!
STM32 DWC2: On some boards vbus may not be connected to the controller and device becomes non-visible for host due to DP doesn't get pulled-up. Additions in this PR can help board bring-uppers to debug the problem, and configure the build.
rebase on the master
thanks
The pre-commit fails because the build doesn't produce .OUT , it seems that there is no relationship with my patches
my local build produce a fonctional .out on the board stm32h573i_dk
Could please tell me what is wrong ?
I noticed that with GCC cubeide, the build produces some warnings , especialy with __ARMCC_VERSION
in the initial H5 commit, i added -D __ARMCC_VERSION=0 as a workaround to remove this warning
If it's easier for you than one huge PR, then I can split it up into smaller PRs that only contain individual and self-contained feature changes
@hathach it seems something is wrong with unit-test.
just re-run and it works now, I also notice @HiFiPhile try to re-run it a few time before. I guess action has some kind of issues previously. Let me try to reproduce the issue with O1 and freertos example, which example you are testing with ? Otherwise, it would be helpful if you could provide reference to Manual where it say some minimum cycle is required for accessing pma
Describe the PR
Resolved the issue where the current UVC Class could not correctly iterate through all interface numbers in the case of multiple VC interfaces and could not open each VS interface under each VC in bulk mode.
Additional context
https://github.com/hathach/tinyusb/issues/2513
Hello Tinyusb,
I didn’t reproduce the issue with examples such as uac2_headset using the same toolchain. (ie GCC CubeIDE in command line)
But the issue is clearly visible in our product.
tinyUsb examples implementations are minimalist, the tu_task() is called in a bare-metal loop with no other heavy tasks sing the CPU.
Our application is different in several points.
Thanks for your PR, however USB_OTG_GCCFG_VBDEN is not defined in all devices, some devices use USB_OTG_GCCFG_VBUSASEN or USB_OTG_GCCFG_VBUSBSEN.
And it's handled in BSP level due to boards and MCU differences: https://github.com/hathach/tinyusb/blob/7c66f9b2a4f302268caeab9f8e63fb6ebd8be466/hw/bsp/stm32f4/boards/stm32f401blackpill/board.h#L94
Fixed the failing constness check by casting to uintptr_t, as done in other places.
Not a TMC expert, just to mention there is no buffering inside usbd_edpt_xfer(), you need to add buffer like how bulk endpoints did:
https://github.com/hathach/tinyusb/blob/9e674fa109348d97fb4280ac534be665f619a4d8/src/class/usbtmc/usbtmc_device.c#L129
Not a TMC expert, just to mention there is no buffering inside
usbd_edpt_xfer(), you need to add buffer like how bulk endpoints did:
Yes, I documented that the buffer must remain valid until the notification_complete callback, since that's what tud_usbtmc_transmit_dev_msg_data already does:
https://github.com/hathach/tinyusb/pull/2494/files#diff-0c276774d...
Sure. My fork of tinyusb has a few extra features implemented for audio class, but didn't get merged as I don't have the boards used by the mainline project for testing.
If you don't need any newer features than my fork (or official support from the project), you could potentially use my fork.
Thank you for your PR!
I will check the PR on my environment. Please wait a few days.
In Windows 11, it was confirmed that multiple VC interfaces were correctly enumerated by applying the PR, but it failed without the PR. LGTM.
@hathach
Just a heads up, the pre-commit action is failing. I'm not sure if we should go ahead with the merge. Could you check it out when you get a chance?
I have confirmed that it is possible to capture 2 streams simultaneously using the following example.
kkitayam:add_uvc_2ch_example
uint8_t const *sbeg = (uint8_t const*)itf_desc + stm->desc.beg;
uint8_t const *send = (uint8_t const*)itf_desc + stm->desc.end;
if (send == _find_desc_itf(sbeg, send, _desc_itfnum(sbeg), 1)) {
TU_VERIFY(_open_vs_itf(rhport, stm, 0), 0);
}
I noticed a typo in the original code. It should be send instead of end. I apologize for the inconvenience. If you could change it to send to achieve the expected behavior, I would appreciate it.
The modification addressed my previous concerns, and I've tested it thoroughly. It works very well.
With the hub plugged into a Pi, please post the output of sudo lsusb -v. Also busting it open and getting the controller IC part number would be useful.
Here's a log after connecting the hub.
Bus 001 Device 002: ID 214b:7250
after-hub-plug.log
@AllTinker-Lance, were you able to get this issue resolved?
@BillPlunkett - I'm afraid not; it's pretty much stalled my project. I never found a workaround which was consistent enough to use, and not enough time/domain expertise to track down the actual issue. 😞 I'm not aware of any alternative libraries for the Pico, so I'm pretty much stuck.
Describe the PR
add tlsr dcd driver enum is ok.
This PR looks great, much needed in my opinion, but these two functions (MspInit and Deinit) shouldn't be here, they should be taken care of in board_init() and not part of this driver.
@HiFiPhile can you review this PR?
Thanks for your PR, I can do coding check, but since I don't have the board I can't test if it works correctly.
@hathach
Just a heads up, the
pre-commitaction is failing. I'm not sure if we should go ahead with the merge. Could you check it out when you get a chance?
I've confirmed that the pre-commit has successfully run on my local WSL machine. In my estimation, I believe the reason why the GitHub action's pre-commit failed is due to the test environment. I think there are no issues with this PR.
It appears the hub is very flaky when talking to low-speed devices if operating in full-speed mode. I attach a Teledyne Lecroy analyser trace showing multiple errors - it appears the host hardware eventually gets upset. My suggestion would be to ensure consistency of the expected packet data toggle in the case of smashed ACKs.
pico host usb hid probe.zip
Thanks @P33M, so the Pico host eventually gets upset. Did you try traces with other hosts, as Matthew tried a Pi5 and Linux laptop, and they also suffered the hub's flakiness but coped better?
I think I am also seeing this issue on a custom STM32H7 board.
For a variety of reasons the host resets the bus (in my case simply sending 0 bytes to a read10 request triggers this with a windows host after a while).
The DCD_EVENT_BUS_RESET message is immediately followed by a DCD_EVENT_XFER_COMPLETE on an IN endpoint, and the subsequent TU_ASSERT(driver,) fails.
Every single other host will use the hub in high-speed mode, which fundamentally changes the signalling involved - communication with the low-speed device is handed off to the hub's transaction translator. See the USB 2.0 spec section 11.14.1.1.
thank @lijunru-hub for the fix, and @kkitayam for reviewing and testing it out.
@hathach, could you please comment on this? This and some other host/hub issues seem to be stalled.
Describe the PR
Currently streaming buffer is shared/re-used when doing probe/commit control, since it is possible for dynamic stream setting, this could lead to memory corruption and lead to hardfault.
Discovered while adding UVC support for Arduino/Circuitpython, I found out that sometime it crashes. Which can be quite easily reproduced by simply launch cheese on Linux, or device mana...
add dedicated variable for probe/commit payload
previously ep_buf[] is used to hold probe/commit payload and _init_vs_configuration() clear/change this while streaming which change the meaning of video payload header.
while streaming and got probe/commit request: ep_buf is wiped out causing
Also I feel that in case of dynamic setting, we shoudln't change the state to PROBING when it is currently at STREAMING. Though I am not too familliar with UVC, and got a bit tired after tracing down the issue, we can revise this state change later on.
usbd.h
stm32h5
when we use webusb to flash our stm32h5 chip , we find not "Selected memory region" shows on the html. shows below
replace
#define TUD_DFU_DESCRIPTOR(_itfnum, _alt_count, _stridx, _attr, _timeout, _xfer_size) \
TU_XSTRCAT(_TUD_DFU_...
sorry, I don't manage to have time fixing my own issues as well and therefore haven't looked at this.
@tyustli thank you for your PR, could you please provide a bit info on the board you are tested with e.g link to the board. I will try to see if it could got one to test with.
thank you very much for the PR. After reviweinng your provided code from stm hal driver and a bit of reading (go through Manual but it does not give any hint). This PR is totally spot-on
Original solution from ST does not need NOP, since count-- does also take 1 cycle. I think the goal is wait 10 cycles, do you have issue if we drop NOP instruction here ?
/* WA: few cycles for RX PMA descriptor to update */
while (count > 0U)
{
count--;
}
This PR is a simple implementation that only adapts enumerations
The link below is the official website
http://wiki.telink-semi.cn/wiki/chip-series/TLSR922x-Series/
Describe the PR
Start adding tuh_deinit(), this also need
Thank you for investigating this issue.
When implementing UVC, I thought that once state transition from PROBING to STREAMING, the buffer used for PROBING becomes unnecessary and can be reused. So, I implemented using the same ep_buf for both PROBING and STREAMING.
Anyway, this issue actually existed and was resolved by your patch. I think that approach is correct.
thanks for the link, I couldn't find any board with the chip, seems like it is not very popular. Not sure how to get one for testing.
thank you for the review, I thought that as well :)
If you don't need any newer features than my fork (or official support from the project), you could potentially use my fork.
Unfortunately I think I need both, I'd hoped I could get away with cherry-picking some bits from your fork but so far it's mostly lead to eclectic bugs and crashes.
Thanks for blazing this trail, anyway, there are surely others out there like me who think using media keys to have the host control the volume is barbaric 😆
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.
This adds support for SCSI_CMD_PREVENT_ALLOW_MEDIUM_REMOVAL via a callback function tud_msc_prevent_allow_medium_removal_cb, very similar to the handling of SCSI_CMD_START_STOP_UNIT.
Properly handling the Prevent / Allow Medium Removal command clears up a "Failed to eject device" error on Linux.
I believe I saw something suspicious with G0 during enumeration, it could be this but I'm not working on it for the moment...
Describe the PR
Fix the following error when executing "make" on Windows.
C:\tinyusb\examples\device\video_capture>make BOARD=frdm_kl25z
process_begin: CreateProcess(NULL, expr 13 >= 12, ...) failed.
C:/tinyusb/examples/build_system/make/toolchain/arm_gcc.mk:77: pipe: Bad file descriptor
Hum... I tried GCC 12 & 13 with command prompt and Mingw bash, but I can't meet the error, what's your setup ?
@kkitayam When you have time could you add ISO endpoint allocation support to UVC class ?
The idea is to avoid USB buffer alloc/free at runtime as it's hard to manage buffer on some devices.
It's pretty simple:
usbd_edpt_iso_alloc in dirver opening to alloc maximum size needed: https://github.com/hathach/tinyusb/blob/67cd8349d614f7a981117ad85d6707e106cd6145/src/class/audio/audio_device.c#L1544usbd_edpt_close and usbd_edpt_open use `usbd_edpt...I'm just trying to compile the Pull request. I'm documenting here my process.
I'm just trying to compile the Pull request. I'm documenting here my process.
- I'm getting an error in dcd_int_handler(uint8_t rhport) . That a semicolon is missing after a declaration.
switch (token) {
case PID_OUT:;
uint16_t rx_len = USBOTG_FS->RX_LEN;
update_out(rhport, ep, rx_len);
break;
I would apprechiate here a warning in compile time, not in runtime...
void board_init(void) {
__disable_irq();
#if CFG_TUSB_OS == OPT_OS_NONE
SysTick_Config(SystemCoreClock / 1000);
#endif
switch (SystemCoreClock) {
case 48000000: RCC_USBCLKConfig(RCC_USBCLKSource_PLLCLK_Div1); break;
case 96000000: RCC_USBCLKConfig(RCC_USBCLKSource_PLLCLK_Div2); break;
case 144000000: RCC_USBCLKConfig(RCC_USBCLKSource_PLLCLK_Div3); break;
de...
I'm just trying to compile the Pull request. I'm documenting here my process.
- I'm getting an error in dcd_int_handler(uint8_t rhport) . That a semicolon is missing after a declaration.
switch (token) {
case PID_OUT:;
uint16_t rx_len = USBOTG_FS->RX_LEN;
update_out(rhport, ep, rx_len);
break;Some compilers don't like declaring a variable inside a switch/case. Added brackets to fix.
Fixed by additional semicolon... see PID...
@dragonlock2 does it support CDC also?
I prefer brackets for readability, didn't know a semicolon also works. The driver supports all of the transfer types needed in USB, so this should work for CDC too.
Can you please give me some hints why I don't get enumeration. What could I do wrong?
I run it in Freertos, in a seperate task. It looks like this:
void task1_task(void *pvParameters)
{
board_init();
// init device stack on configured roothub port
tud_init(BOARD_TUD_RHPORT);
if (board_init_after_tusb) {
board_init_after_tusb();
}
while (1) {
tud_task(); // tinyusb device task
tud_cdc_n_write_str(0,"Hello, World!\r\n");
...
@greenscreenflicker let's continue this part of the discussion on https://github.com/hathach/tinyusb/discussions/2525 and keep comments here focused on the PR
@HiFiPhile
Thank you for your comment and for attempting to reproduce this issue.
I noticed that the description of this issue lacks information about my environment.
Hum... I tried GCC 12 & 13 with command prompt and Mingw bash, but I can't meet the error, ...
I don't know if this is the correct fix, but @kkitayam is correct that GNU Make has special logic that fires on Windows/DOS to deal with systems without a Bourne shell clone. The behavior is described in greater detail here. Also relevant source.
@kkitayam Thanks for your explanation, I reproduced the issue and this fix works well.
@Marcus2060 I come back to this.
So the problem seems to be a different behavior of TinyUsb Audio Class 2.0 between Windows, Linux (16.16 ok) and MAC (10.14 ok ... but with the trick MAXPacketBytes=3 ) .... ??
No the stack works (tries to) the same way across all OSes, the issue is some OS doesn't respect the UAC specification as I mentioned earlier.
The Rp2040 is a full-speed device and I don't need large audio streaming traffic. So would it be possible with the TinyUsb stack to...
Windows 11
RP2040 custom board.
Full source code and full schematic can be found in my repository.
I'm trying to complete RP2040 based custom number-pad firmware.
Quick link to few necessary files:
Describe the PR
Add an example of 2ch video capture.
Each channel represents an individual camera, but the video format used is the same.
Additional context
For reference, please see #2520.
Not a TinyUSB issue, I suggest you to check linker and disassembly output to ensure your tud_cdc_rx_cb implementation is correctly used.
Not a TinyUSB issue, I suggest you to check linker and disassembly output to ensure your
tud_cdc_rx_cbimplementation is correctly used.
simple_np.elf.map file have following lines:
.text.tud_cdc_rx_cb
0x10000664 0x34 CMakeFiles/simple_np.dir/board/usbd.cpp.obj
0x10000664 tud_cdc_rx_cb
Isn't this correct?
LGTM, hit it once, in STM32Cube it's not enabled.
Please check the disassembly output of final binary.
https://github.com/hathach/tinyusb/blob/3ec22e24ed3e8169b7aa8bd51f86f95dda0e6002/src/class/cdc/cdc_device.c#L457
You can start with official examples on supported board, like adding following code to cdc_dual_ports example.
void tud_cdc_rx_cb(uint8_t itf) {
static uint8_t state=0;
board_led_write(state++);
}
Please check the disassembly output of final binary.
You can start with official examples on supported board, like adding following code to
cdc_dual_portsexample.void tud_cdc_rx_cb(uint8_t itf) { static uint8_t state=0; board_led_write(state++); }
10000664 <tud_cdc_rx_cb>:
10000664: b510 push {r4, lr}
10000666: b...
there is no reference which calls this callback cdcd_xfer_cb in full disassembly.
But it's there in your attached disassembly.
And even more, basic examples are all working well if descriptor has no HID + CDC combination.
So cdc_dual_ports works ? In the case of HID + CDC, does CDC data receive actually work (by tud_cdc_n_available and tud_cdc_n_read in main loop) ?
If the version of tinyusb in pico-sdk has corrupted, how can I replace it to other distribution?
You ...
there is no reference which calls this callback cdcd_xfer_cb in full disassembly.
But it's there in your attached disassembly.
Yeah, but the instruction that calls the address of that function cannot be found.
And even more, I testedTUD_CFG_CDCvalue usingvsprintf, and it saysusb: cdc: 1.
tty_printf("usb: cdc: %d.\n", CFG_TUD_CDC);
And even more, basic examples are all working well if descriptor has no HID + CDC combination.
So `cdc_dual_po...
Describe the PR
Auto label new issue/PR
Comment : https://github.com/hathach/tinyusb/pull/2515#pullrequestreview-1954563527
Hello Tinyusb team
Happy this patch fixes a potential issue for other MCU families.
I would like to notice, I found a second issue on synopsis IP ( for H735 & H757), but I didn’t provide the path because the issue vanished with an rebase upstream. But it was characterized with a previous build in CubeIDE and -O3 -oFast.
The characterization was an in an infinite loop in reset_core()
->while (dwc2->g...
@Lurcy38 could you please confirm if we could remove the 'nop' instruction and just keep the count-- is enough ?
Comment : #2515 (review)
Hello Tinyusb team
Happy this patch fixes a potential issue for other MCU families.
I would like to notice, I found a second issue on synopsis IP ( for H735 & H757), but I didn’t provide the path because the issue vanished with an rebase upstream. But it was characterized with a previous build in CubeIDE and -O3 -oFast. The characterization was an in an infinite loop in...
yes, you can remove the "nop", I added this nop by safty, to consume more time in case of higher frequency and force the compiler to keep the loop as is
@hathach Could you take a look of my pending PRs when you have some time ? Especially this one is necessary to make audio class running reliably.
Originally posted by IngHK March 5, 2024
I examined the CPU and USB usage on my host with STM32F401 (ARM M4 CPU 84 MHz) and MAX3421 (SPI 21 MHz).
With a CDC ACM device I saw that the CPU, SPI and USB are mostly busy handling the input stream endpoint.
The endpoint responds with NAK because there is no new data, and handle_xfer_done() in hcd_max3421.c causes the same stream to be repeated immediately (no ...
@hathach Could you take a look of my pending PRs when you have some time ? Especially this one is necessary to make audio class running reliably.
sorry, will review this asap.
thanks for confirmation, fixed and closed now
Tested works well on STM32F407-DISCO and Nucleo-STM32G0B1.
I updated lib/tinyusb of pico-sdk to latest release.
PS C:\ARM\RP2040\pico-sdk> git submodule status
72ef1732c954d938091467961e41f4aa9b976b34 lib/btstack (v1.4-2371-g72ef1732c)
8ef38a6d32c54f850bff8f189bdca19ded33792a lib/cyw43-driver (v1.0.1)
239918ccc173cb2c2a62f41a40fd893f57faf1d6 lib/lwip (STABLE-2_1_0_RELEASE-548-g239918cc)
a77287f8fa6b76f74984121fdafc8563147435c8 lib/mbedtls (v2.28.1-36-ga77287f8f)
86c416d4c0fb38432460b3e11b08b9de76941bf5 **lib/tinyusb (0.15.0)**
...
Describe the PR
implement hcd_deinit() for max3421
This PR is a first draft (not for merging) as a basis for further discussion and testing.
It is intended to fix the problem as discussed in #2510 / issue #2541
The change means that in the case of a NAK, the transfer will only be repeated in the next frame (triggered by frame IRQ).
Describe the PR
use usbreset to reset built-in usb 2.0 hub VIA Labs before each test
Please mention in the files, that it only works with some of the devices, having the right module. (H/D in the grafics below)
Not sure what @hathach would prefer, but I think the driver names are enough documentation. dcd_ch32_usbfs.c is for the USBFS/OTG_FS IP and dcd_ch32_usbhs.c is for the USBHD IP.
Notably some CH32V20x only have the USBD IP which I believe may be compatible with the STM32 driver.
I would be very interested into this as have 2 boards with v203(CH32V203G6U6 and CH32V203C8U6)
If you need any test let me know but love to have normal USB access with tinyUSB
@ddB0515 Note that CH32V203G6U6 is not supported, while CH32V203C8U6 probbably is.
The naming by wch (@openwch) of the devices in unfortunate.
@greenscreenflicker will CH32V203G6U6 work at least as HID/CDC? as that is supported as USB Device or I'm wrong?
@ddB0515 CH32V203G6U6 doesn't work with CDC/HID. I use that MCU also, and have the problem. See here:
https://github.com/hathach/tinyusb/discussions/2525#discussioncomment-8912923
FYI, this seems to be mention in H503 Errata https://www.st.com/resource/en/errata_sheet/es0561-stm32h503cbebkbrb-device-errata-stmicroelectronics.pdf
So maybe the delay is not enough for low speed ?
This causes the correct "umount" callbacks to occur before deiniting a root hub and its drivers.
@ddB0515 @greenscreenflicker as I expected the existing dcd_stm32_fsdev.c works for the USBD of CH32V20x. See dragonlock2/miscboards/wch/mouse_jiggler. Let's continue discussion on https://github.com/hathach/tinyusb/discussions/2525 and keep this PR focused on the USB OTG/FS driver.
yeah, H5 running at max 250Mhz, which is 4ns per cycle, the above loop do check, minus, then jump which take 3 cycles per run, therefore only delay 3410 = 120ns, I guess other interrupt handler contribute to the delay. We may consider to add back a few nop.
For low speed, it is definitley not enough, we should check the curent linkspeed and do delay accordingly, we need to burn some cycles anyway. I will push an update for this later.
Describe the PR
Change labeler token
When porting examples to a custom OS the missing forward declaration of board_millis creates problems.
The forward declaration lets custom OS ports use the board_api.h for use of board_usb_get_serial and implement board_millis anywhere if needed with the correct signature.
The CDC examples include the bsp/board_api.h in usb_descriptors.c for use of board_usb_get_serial. board_api.h also includes implementation of board_delay which uses board_millis. But in case of `OPT_O...
Any update? This is a definite bug introduced after 0.15 and still there in the latest code
Describe the PR
use while loop to remove all of downstream device if removing an hub. Previously using event queue, which is not nice.
Look good, thank you.
note: ci failed due to my incorrect labeler workflow and can be safe to ignore
thank you, I made a change to simply use hub_addr=0, hub_port=0, which will also remove all the downstream devices by process_removing_device()
Note: https://github.com/hathach/tinyusb/pull/2550 also helps to make removing an hub nicer without using event queue to unroll recursive removal.
IMXRT: update linker scripts so that the code section does not start at 0x0.
Describe the PR
On those cpus that have the internal RAM start at 0x0, this sets the start of ram to 0x20, so that we can never end up with a valid piece of code living at address 0x0. That's a bad thing.
Additional context
This happens when you put stuff into CodeQuickAccess memory.
all of these linker scripts are directly from the mcu directory. The downside is that if the upstream mcu re...
Linux
Feather nRF52840 Express
In the function board_get_unique_id from hw/bsp/nrf/family.c, here is the relevant section of the code -
size_t board_get_unique_id(uint8_t id[], size_t max_len) {
(void) max_len;
#ifdef NRF5340_XXAA
uintptr_t did_addr = (uintptr_t) NRF_FICR->INFO.DEVICEID;
#else
uintptr_t did_addr = (uintptr_t) NRF_FICR->DEVICEID;
#endif
const uint8_t* device_id = (const uint8_t*) did_addr;
for...
The device ID is read from the NRF_FICR and directly accessed in the subsequent for loop without any checks on whether the ID is appropriately mapped or not. This can cause NULL pointer or arbitrary writes in a tampered environment.
Every device register can be null in a tampered environment, it's impossible to check every registers.
Others
Raspberry PI Pico
Custom firmware. You can see my whole project here: https://github.com/theosib/pico_vga/tree/main
I'm trying to debug TinyUSB. I want to find out why plugging in two USB devices at once results in no devices found. You can see more detail at https://github.com/raspberrypi/pico-sdk/issues/1680.
The first thing I did was set CFG_TUSB_DEBUG to 3 in my project's tusb_config.h, which is supposed to g...
The first thing I did was set CFG_TUSB_DEBUG to 3 in my project's tusb_config.h, which is supposed to get included by TinyUSB for various config options. But this didn't work. I think it's because src/common/tusb_debug.h doesn't have an #include directive for this.
Either pico-sdk or you messed up the includes.
undefined reference toep_dir_string'`
Semms 6dc714b has some left ups...
Actually, I updated the TinyUSB submodule and am using the latest code.
I'll try later to trace the includes, but in any case, setting CFG_TUSB_DEBUG in my tusb_config.h didn't do the job. Not sure why.
Linux
Raspberry Pi Pico
Custom firmware. You can see my whole project here: https://github.com/theosib/pico_vga/tree/main
TinyUSB detects no new devices when two are plugged in at once
Plug in a keyboard and mouse simultaneously.
I'm u...
I went ahead and pasted in the missing ep_dir_string, and I'm able to get debug messages. However, there is now a panic that occurs that did not occur without the debug messages.
Those messages are a bit spammy. I reduced the debugging level to 2, and this is what I got:
[0:] USBH DEVICE ATTACH
Full Speed
[0:0] Open EP0 with Size = 8
Get 8 byte of Device Descriptor
[0:0] Get Descriptor: 80 06 00 01 00 00 08 00
Transfer complete
on EP 00 with 8 bytes: OK
Buffer complete
Transfer complete
on EP 80 with 8 bytes: OK
[0:0] Control data:
0000: 12 01 00 02 09 00 00 40 |.......@|
Buffer complete
Transfer complete
on EP 00 with 0 b...
The panic is coming from "hdc_rp2040.c", here:
tusb_speed_t hcd_port_speed_get(uint8_t rhport)
{
(void) rhport;
assert(rhport == 0);
// TODO: Should enumval this register
switch ( dev_speed() )
{
case 1:
return TUSB_SPEED_LOW;
case 2:
return TUSB_SPEED_FULL;
default:
panic("Invalid speed\n");
// return TUSB_SPEED_INVALID;
}
}
The value being returned by dev_speed() is zero.
should be fixed, I normally only have DEBUG=2 with rp2040 since log via UART can mess up with timing when DEBUG=3.
Thanks for opening the issue. FICR (factory ID register) is read-only and cannot be re-programmed by any mean. I don't think it matter much in pratical when running actual hardware.
I still don't understand why we need to make this change, can you elaborate it please. Please note that these linkers are only used by tinyusb examples only.
Totally true. I just got burned when I ended up with a function pointer at address 0x0.
Then when I did the callback thing:
if (funcptr)
funcptr()
funcptr was placed at 0x0 and never got called.
Not an issue for the examples since they don't place anything in fast ram. But when taking the examples and building off of them, it could be an issue.
It's totally fine to close this if not worthwhile.
This can be overcome in user code. See https://github.com/UKTailwind/PicoMite/blob/main/USBKeyboard.c for how I do it. Note you MUST NOT issue any tuh_hid_send_report commands or similar in the mount callback or you will hit issues
I've solved this but does anyone read these issues? The issue is that tinyusb re-uses an itf without clearing the protocol and does not set it if the new protocol is zero
fix:
static hidh_interface_t* find_new_itf(void) { for (uint8_t i = 0; i < CFG_TUH_HID; i++) { if (_hidh_itf[i].daddr == 0) { _hidh_itf[i].itf_protocol=0; //Clear the protocol - needed if the new protocol is zero return &_hidh_itf[i]; } } return NULL; }
Can you give me a hint about how this example overcomes the problem? I've looked through the mount code, and I'm not seeing anything special. Also, my mount code doesn't send any reports.
Thanks for the quick fix!
Regarding my other bug report, however, the USB problem persists, and there is a panic that occurs when DEBUG=2 that doesn't occur when DEBUG=1 or 0.
function callback at address 0x0 is kind of odd, though totally valid. Normaly that is for reset/entry/start. However, within the scope of tinyusb examples, we don't really need it and I really don't want to maintain these linker script if I don't have to. Thank you.
Note: in the future I will try to migrate from weak callback to weak/ref default implementation. It will elimiate the need for the if (func_cb) func_cb(), this is for keil compatible see #1018
What you said definitely makes sense. But a simple Null check before using the variable in my humble opinion would not cause much performance difference. Nevertheless, I also noticed that the length of the id array is being passed to the function and isn't being used which I'm assuming is 8 bytes since the code tries to access 8 bytes of id. Removing such stale variables would also be a nice thing to see in future.
I don't know anything about USB, so this is slow going for me, but it looks like the problem is being caused by an attempt to set power management on a hub, and TinyUSB may not be giving it sufficient time to complete that setup before performing further communication. I've tried putting delays in various places, but I'm stabbing randomly. If someone who knows what they're doing could give me some hints about where I might put strategic delays, that would be really helpful.
Basically, we h...
It also occurred to me that perhaps the end point it's trying to get the speed for doesn't really exist, so I modified hcd_port_speed_get to return TUSB_SPEED_INVALID on an invalid speed. It got a little further and then died here:
void __tusb_irq_path_func(_hw_endpoint_buffer_control_update32)(struct hw_endpoint* ep, uint32_t and_mask,
uint32_t or_mask) {
uint32_t value = 0;
TU_LOG(3, "Enter _hw_endpoint_buffer...
perfect, thank you. I rebased and make some minor clean up. It is good for the merge. Sorry for late review.
to clarify: board_get_unique_id() is not part of tinyusb source, it is just an application-scope, exists to have usb example running only. Each application will has its own implemenation . Therefore I think It shouldn't be targeted as security for tinyusb, you should target files in src/ instead.
I finished work now and It's ready for review and merge.
It can handle up to 10 retries per frame adjustable by CFG_TUH_MAX3421_MAX_ATTEMPS_PER_FRAME.
With value zero it's compatible with endless retries as before.
Describe the PR
fix #2447
thank you for find the root cause, it should be fixed by 2559
Describe the PR
move walkaround to dcd_ep_ctr_rx_handler(), increase cycle_count from 10 to 20 (40 cycle)
I made an follow up to move delay to the interrupt handler instead. Per errata we should delay first before any attempt to read pma region. This assume read rx count is always the first access to the region (which is true most of time but not always). Also do some reformat and rename the header.
Note: initially I want to check the link speed then delay more if low speed, however, a quick check from manual does not show how link speed is detected, and low speed is super rare these days, so...
For more details see https://github.com/hathach/tinyusb/discussions/2561
thank you for the pr, look like I already "fix" the doc while copy the contents from the readme.md previously.
thank you for your PR, please follow review to make suggested changes
please change this more generic
#if !defined(USB_DRD_BASE) && defined(USB_DRD_FS_BASE)
#define USB_DRD_BASE USB_DRD_FS_BASE
#endif
for GPIO that is not available in H503, we can just use #ifdef to check if macro exist e.g
#ifdef __HAL_RCC_GPIOE_CLK_ENABLE
__HAL_RCC_GPIOE_CLK_ENABLE();
#endif
please keep the function name SystemClock_Config() as it is
Ok, I will restore original name.
Ok, it can be done.
In such a case, __HAL_RCC_GPIOx_CLK_ENABLE() should stay in family.c, right?
Great idea, I will change that.
I'm comparing the success and failure cases. The success case is when only the keyboard (with its internal hub) is plugged in, while the failure case has the mouse also plugged in. The logs are identical up to a certain point.
Everything is pretty much the same as I shared above, ending with this:
HUB Set Feature: PORT_POWER, addr = 5 port = 3
[0:5] Class Request: 23 03 08 00 03 00 00 00
hw_endpoint_init dev 5 ep 00 xfer 0
dev 5 ep 00 setup buffer @ 0x50100180
endpoint control...
Describe the PR
add NCM transfer termination by ZLP if necessary.
If NCM transfer aligns with (multiple) USB packet size the transfer has to be terminated with a ZLP.
This PR also lowers the likelihood of needing a ZLP to terminate a transfer.
Additional context
The driver implementation increased likelihood for this happening by always sending a multiple of 4 bytes in an NCM transfer, caused by including the padding bytes to the next NCM datagram, this however is not require...
I fixed trailing whitespace error, could you please re-approve PR? All checks should pass now.
@battlesnake @Gadgetoid Sorry for the extra long delay, finally I reviewed the changes and it's ready to merge:
CFG_TUD_AUDIO_ENABLE_INTERRUPT_EPusbd.h.uac2_headset example, now volume can be changed by on-board button press (Tested with Nucleo-G0B1RE on Windows 10 and Linux)Thanks a lot. I re-tested on stm32h503nucleo and it works too.
Perfect, thank you very much of the PR. Though I made some changes to
tested and confirmed it only send 1 token per frame

void HAL_PWREx_EnableUSBVoltageDetector(void);
void HAL_PWREx_DisableUSBVoltageDetector(void);
void HAL_PWREx_EnableVddUSB(void);
void HAL_PWREx_DisableVddUSB(void);
#endif /* PWR_USBSCR_USB33DEN */
h563 and h503 are both supported, this can be closed
I try to resolve conflict with master, and also want to make changes to the PR. Please edit PR to "allow maintainer to edit this pull request"
@hathach It doesn't work if cfg->max3421.max_nak is the maximum value.
Then it's running endless, because ep->state remains EP_STATE_ATTEMPT_MAX and that flags pending.
We really need an additional state "suspend", if the last attempt is NAKed.
I'll fix it soon...
That is ok max attempt can also be inferred as no nak limit as well. To be honest a usb frame will probably hold less than 10 retries due to back and forth spi transactions
@hathach I think, it's a little bit confusing, when last "attempt" is not a real attempt but instead used as suspend state.
On assembler level is it the same, but it's not easy to understand the code.
If you like I would create a commit with TU_VERIFY
Describe the PR
follow up to #2543
thanks, I already made an PR to limit it https://github.com/hathach/tinyusb/pull/2565
Describe the PR
correct the max nak (min instead of max)
recently I switch to use weak as the default implementation of callback to be compatible with keil #2239
https://github.com/hathach/tinyusb/blob/master/src/device/usbd.c#L48
the other callback header can work with weak_import, but this style seems to require actual weak and cause the compile issue with unit-test (since test include mocking of dcd layer).
Maybe I should use weakref/alias or unify them all to default implemenation, will revise later. We probably need to keep t...
Describe the PR
TUP_DCD_EDPT_ISO_ALLOC into tusb_mcu.hvideo_capture and video_capture_2ch example work on NUCLEO-G0B1RE with ISO endpoints, previously only bulk workAdditional context
Now we can remove the buggy buffer free/realloc code from fsdev and dwc2 driver.
Is it possible that one VS interface has multiple endpoints, one input header and one output header ?
Maybe this #ifndef can cover this whole for loop, since bulk endpoint doesn;t change.
Describe the PR
Forgot to check cfg_param not NULL
Sorry for the extra long delay
Looks like three weeks since I bumped it, that's a fast turnaround IMO and it's hugely appreciated! (We'll pretend the PR isn't years old because something something glass houses and stones 😬)
I have updated my code and replaced the tinyusb submodule in my local clone of pico-sdk. Everything works as I'd expect with our RP2040-based design. Including mute/unmute. Full changeset on my not-actually-a-headset-but-two-speakers codebase here: https://github.c...
Describe the PR
catch error from labeler
Based on my understanding, one VS interface can have up to 2 endpoints, but one VS can only have one input header or one output header. Cite the standard.
When a VS interface has two endpoints, one is used for streaming video, and the other is used for capturing still images. Cite the standard.
...
I agree with your comment. I believe that the #ifndef can be moved to outside the for statement.
As described below, ep[1] is limited to bulk for still image capture, so there is no need for a for statement.
Please give me a few days. I would like to check the PR in my environment later.
I prefer the first changes, but just wrap it with ifndef to compatible with both version of sdk. I will make the change myself since it is quick enough.
I mean wrap this with ifndef to compatible with both sdk
#ifndef EP_ALLOCREQ
#define EP_ALLOCREQ(ep) (ep)->ops->allocreq(ep)
#endif
thank you, I added check if usbdev_allocreq failed, and add note for sdk v2, v3. Will merge when ci passes
Tested on rp2040 and it works well. We may make 2 stream a bit different so that it is clearer which is stream (we can do it as follow-up PR no problems).
I add the new example to cmakelist include directoy, seem like some small MCU has SRAM overflowed with 2 stream buffer. I will check and exclude (add them to skip.txt) later on.
Describe the PR
@tannewt
Looks good! Thank you!
look good, thank you. I update it a bit to use dir variable, will merge when ci passed
OK. I finished work for now.
It's ready for review and merge
Hi @hathach
I read that this option is only for user-owned repositories, but I sent you an invitation to have permissions on the repository.
Just push an update uvc 2ch example to stream0 use yuy2, stream1 use mpeg, this help reduce sram requirement for example, also provide different format (uncompressed & mpeg)
fixing build with lpc18xx, will fix more ci next
This was written from scratch using the datasheet and tested on a SAMD21 (using SparkFun SAMD21 Mini Breakout).
However, it should also work with SAMD51 boards, I don't have one for testing though.
For some reason, when compiling the host/hid_controller example (modified by setting CFG_TUH_HUB to 1) from tinyusb, GET_DESCRIPTOR times out when connecting devices via USB hub.
When I use tinyusb within my platformio pr...
With new changes for camera 2 bulk is ok but iso gives a laggy output.
I think it's a bandwidth issue since I counted 63 bulk packets in 10 sof, which gives about 400kB/s data rate.
Iso packet is limited to 248kB/s, I tried to increase CFG_TUD_VIDEO_STREAMING_EP_BUFSIZE to 511 but _videod_streaming_itf[1].max_payload_transfer_size stayed at 248.
With new changes for camera 2 bulk is ok but iso (#2567 applied) gives a strange output on STM32G0.
In the capture STM32G0 sends packets every frame while STM32F4 sends much less.
Then I added a gpio toggle in
tud_video_frame_xfer_complete_cb, for camera 1 it toggles every 100ms, for camera 2 it toggles about every 1ms.... Seems fsdev driver need some fix...
yeah, seems like fsdev specific...
resolved the conflict, I don't why, but your PR contains also lots of unrelated changes to other files such as cdc_msc_freertos, nrf etc.. probably the git branch is messed up somehow. I have reverted those changes.
everything is all good. I have change the 2 stream to have different format. @kkitayam please revise the changes in recent commit. Thank you for another brilliant PR. Let me know if this change make sense to you, and we can merge this.
@HiFiPhile regarding the fsdev driver issue with 2 ISO stream. We probably need to have its own issue/pr to fix.
@kkitayam I have changed the 2 stream to
This is to show that 2 stream can have different format and is slightly different. Also it save sram since many of MCUs can only have enough for yuy2 dynamic.
regarding the fsdev driver issue with 2 ISO stream. We probably need to have its own issue/pr to fix.
Yeah, I've nearly sorted it out. For ISO transfer fsdev doesn't clear endpoint state upon transfer completion, once next IN token received it just resend current packet (even CPU halted) and trigger rx interrupt without way to mask...
The issue wasn't caught as in old examples the number of IN token corresponds to packets needs to send, but here all ZLP sent automatically are triggeri...
Describe the PR
Tested on NUCLEO-G0B1RE with audio, video and cdc_dual_ports examples.
Describe the PR
Follow #2567
Setup is received, somehow Data packet ending is corrupted...
USBD init on controller 1
sizeof(usbd_device_t) = 44
sizeof(dcd_event_t) = 12
sizeof(tu_fifo_t) = 12
sizeof(tu_edpt_stream_t) = 24
CDC init
guid, gsnpsid, ghwcfg1, ghwcfg2, ghwcfg3, ghwcfg4
0x00001100, 0x4F54281A, 0x00000000, 0x229ED590, 0x03F403E8, 0x17F00030
Fullspeed PHY 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 ...
0000...
Just ordered an frdm k66f from ebay to test out this pr. Couldn't find a k28, but I guess it would be much more similar than rt1170. It will take a month or so for it to be delivered to my desk so please be patient.
I had check that the PR works on my RP2040 and RX65N target board.
It's a great idea! I agree with you.
It seems like EP0's IN FIFO can't be located at the end of RAM, otherwise IN packet is corrupted like above.
Thanks for your check, although these 2 mcu don't use fifo allocation feature. I saw allocation is needed in dcd_rp2040 so it would help once it's implemented, not sure the case of RX.
@hathach Maybe my dwc2 PR crashed your HIL test setup...
superb !! Thank you very much, let give me a bit of time for reviewing (still need to wrap up other work first).
thank you, please give me a bit of time to review.
thank you for your PR. Everything work perfecty now, I made some changes to get it built with all examples. Currenlty ci failed on hil test, but that is a totally different issue by local pi4 setup. Will fix that in master.
Describe the PR
Make it possible to configure max3421 interrupt edge/level polarity and pulse width. Default to negative edge 10.6 us
@hathach Maybe my dwc2 PR crashed your HIL test setup...
Not at all, pi4 seems to struggle with usb stability. I need to do manual reboot after a while. Changes look great, merge now
thanks for the fix, though I notice this PR disable double buffering for ISO (default behavior). If possible we should keep this, otherwise it may not keep up with 1023 packet size.
I would prefer to keep double buffering for ISO if possible. Otherwise it may not keep up to 1023 byte per packet. Maybe we could find anothe way to fix this ?
great, better clean these dead code while we still remember :)
thank you very much for the PR and sorry for late response. I kind of forgot about these in my pile of email.
I would prefer to keep double buffering for ISO if possible. Otherwise it may not keep up to 1023 byte per packet.
In fact currently double buffering is not configured correctly, it's enabled but both buffer are pointed to the same address.
https://github.com/hathach/tinyusb/blob/d33fe38a6257bcdd60f51a57c9fd19ce2ad1f202/src/portable/st/stm32_fsdev/dcd_stm32_fsdev.c#L965C1-L967C76
Maybe it's better to fix the buffer stuff and enable double buffering, since on older chips there is no m...
This expression has no effect (because osal_queue_delete has no external side effects).
thank you for the PR. I have pushed the update for class driver deinit() as well. Haven't tested this thoroughly, but I guess we could fix it later on should there is any issues.
Static function audiod_set_fb_params_freq is unreachable (audiod_set_interface must be removed at the same time)
since on older chips there is no mention that ISO double buffering can be disabled:
Yeah it's broken on L0...
@hathach When I use CFG_EXAMPLE_VIDEO_READONLY I got incorrect output on stream 1 with both fsdev and dwc2 driver.
since on older chips there is no mention that ISO double buffering can be disabled:
Yeah it's broken on L0...
thanks for testing it out, seems like we will definitely need double buffer for ISO.
@hathach can help somehow to complete this PR?
Describe the PR
I met a racing condition with video examples (strangely I didn't caught it in #2538).
With ISO alloc stm->desc.ep[0] is no longer cleared, tud_video_n_streaming() return true when interface is initializing but usbd_edpt_iso_activate() is not yet called. Resulting usbd_edpt_xfer()` called before endpoint is ready.
I think you need to use 2 separate try {} block for Adafruit membership and contributor check
I think you need to use 2 separate
try {}block forAdafruit membershipandcontributorcheck
Ah thanks, I guess so, but GPT said I only need 1, damn.
sorry for late response, thank you for the PR. Everything makes sense. Though the usba driver is rename to rusb2 and has been generalized to work with ra family. Though I noticed there is some hipcup espcially msc example does not work anymore with rx. Haven't spent much time to testing more. But it has nothing to do with this PR. Maybe I will revisit and/or file an seperated issues for that later. Will merge when ci passes.
thanks, actually we don't need the line for indicator, gcc would be able to emit the exact location. We can just replace LINE with TU_COUNTER to make it consistent with the followed ``#else`.
thank you, look good to me. Note: host can acutally do probe while streaming to dynamic change streaming parameter. So I guess the current state does not accurately reflect the streaming state. Though we will do a full revise later on.
Describe the PR
more try catch for labeler
Describe the PR
Otherwise video output is funky...
Describe the PR
Otherwise video output is funky...
Thank you very much for merging the PR.
Yes, I also noticed that there is an issue with the msc example code. If I remember correctly, the issues start as soon as USB version 2.1 is specified and certain msc descriptors are read.
I think there are even some open discussions regarding this topic.
I'll be back to work next week. If you want, I could probably provide further information.
Thank you very much for merging the PR. Yes, I also noticed that there is an issue with the msc example code. If I remember correctly, the issues start as soon as USB version 2.1 is specified and certain msc descriptors are read. I think there are even some open discussions regarding this topic.
I'll be back to work next week. If you want, I could probably provide further information.
that would be awesome, since I am not really familliar with rx much.
Describe the PR
add permission to lable issue/pr
Describe the PR
based on and supersede #2050, since 2050 does not allow maintainer to push update.
history log is reserved, once this is merged, 2050 is marked as merged as well.
Superb! the while loop is my terrible typo. Thank you for the fix and sorry for late response. I was buried in pile of works. Though since your PR does not allow maintainer to push to resovle the conflict. To reduce further delay, I have create https://github.com/hathach/tinyusb/pull/2584 based on this, with history/author reserved, once that is merged, this will be marked as merged as well.
I've reworked the PR, now it has correct ISO double buffering handing.
It's enabled only for device with 2048b PMA, smaller devices has 2 buffers point to the same address as before, otherwise they will fail to run some examples. In my tests I didn't see single buffering cause any issue.
Tested on L0, G0, H5 to be sure nothing broken.
I put each change in one commit hope it's easier to review...
For 5ade917 I think it's better to double Tx fifo size only for port who has 4096b buffer. As Rx buffer size is already doubled, port with 1280b buffer has very limited usable space. Also 1280b port running in FS doesn't need much performance.
For 5ade917 I think it's better to double Tx fifo size only for port who has 4096b buffer. As Rx buffer size is already doubled, port with 1280b buffer has very limited usable space. Also 1280b port running in FS doesn't need much performance.
I think you are right on this, now thinking a bit more, even with 4096, having an in + out with 512 can take up to 2K if we double both of them. It is probalby ju...
Describe the PR
dwc2 set txfifo empty level to complete and change back fifo tx to normal size
follow up to #2584
Describe the PR
Supersede and close # 2097, tusb_types.h should be as primitive as possible for external driver to include without include the whole stack.
Sorry for late response, synopsys dwc2 driver has been moved to src/portable/synopsys/dwc2/dcd_dwc2.c, since #2333 FIFO size is fixed at connection and no dynamic adjustment is done. Please test if it works.
Since #2333 there is no more dynamic FIFO size adjustment, should fix the issue.
Superseded by #2586 which is lighter than this PR. Thank you for bringing this up, and sorry for the late response.
right, I think this should not be an issue with latest dwc2 driver, feel free to re-open or file an issue should you still have problem with this.
thank you for the PR and sorry for late response. I have rebase to resolve conflict in the latest as well a minor format. The code look great, will merge when ci passed.
right, we may remove the dcd_edpt_close() API in the future as well. This should be marked as solved. Feel free to re-open or file an new issue/pr should it still be an issue. Thank you
I'm thinking about set configuration request, should FIFO flushed in dcd_edpt_close_all before switching ?
thanks @Rbb666, I just pull out my ram41 to test with, this PR indeed causes hanged (block wait) with msc_cdc example. This should be reverted, since the solution does not work as expected and seems to cause more serious issue.
Describe the PR
#2245 seems to cause some unreasonable blocking wait. msc_cdc example cannot enumerate normally with ram41 evk. Probably more testing and tweaking should be done to re-apply the changes.
maybe worth retested after (will try myself as well) https://github.com/hathach/tinyusb/pull/2587
谢谢,我只是拿出我的 ram41 进行测试,这个 PR 确实会导致挂起(块等待),举个例子msc_cdc。这应该被还原,因为解决方案没有按预期工作,并且似乎会导致更严重的问题。
Yes, this is a problem I detected on Renesas ra8d1. I hope it can be fixed as soon as possible.
already reverted by #2587
Describe the PR
remove bit field since it will cause unncessary bitop and this does not save any sram usage for this particular struct
closed since a better approach is implemented by #2588
superb !! thank you, will review and test this out soon enough.