#tinyusb
1 messages ยท Page 16 of 1
There is some similarities with #813 as they both send 8 bytes payloads. @Makurisan
There is a series of packded struct, I think we should simply this by putting only 1 pack begin and 1 pack end for the all struct define. Just put an comment to tell we need to remind us is good enough.
Thank you very much for your effort putting into this PR. This is lots of work and testing, there is also fixes to existing rx driver as well. However, the weak function walk-around is not good enough and is a total deal breaker. It is totally not your fault but rather mine for choosing the weak function for user convenience and assume that most toolchain would support it.
I think we either have to come up with another walkaround for weak function or have to merge other changes first. And ...
the bit field order is default to right, maybe we don't really need to define this. If you still want to define this, I think it is best to just put only one at the beginning of the struct declare, and one at the end like struct begin above.
there is no need to check for compiler, if there is other one, it will be handled by the tu_le16toh().
These bugs are caused by the failure to check request->wLength.
hidd_control_xfer_cb
case 1
if request->wLength > the size of p_hid->epin_buf it could lead buffer out of bound read.
case HID_REQ_CONTROL_GET_REPORT:
if ( stage == CONTROL_STAGE_SETUP )
{
uint8_t const report_type = tu_u16_high(request->wValue);
uint8_t const report_id = tu_u16_low(request->wValue);
uint16_t xferlen = tud_hid_get_report...
have you tried it, and do you have any examples to prove it ?
The port still need bsp to verify that mcu work with existing project on mm32. However, it is good as intial PR.
Note: I have removed the keil project .zip, such as binary file is not allowed in this repo. You could probably provide it as additional, add-on to your sdk.
This PR should be closed after #869 is merged. I think it is just better to add board support based on 869 instead of using this PR.
no, I found these by reading the code
Ah thanks, I thought you would have a running examples so that we could quickly test it out and fix it. Regardless, these are valid issue. Ultimately we shouldn't just host for its length.
- The 1) can be fixed by limited the requestlength to the endpoint size.
- For 2 DFU, it is newly added, I have an plan to enhance it later on, will keep this in mind.
- For 3) same as 1.
Thanks for your issue, if you have time please submit PR if possible. Otherwise, It is great enough, I will try...
Superb !! Thank you very much, I am still lacking behind to ISO transfer. I have the RX65n board now, but haven't got time to get it setup and test. Though, this PR look great, I will try to catch-up with testing later on. #859 also modify the same driver, do you see any conflict. If not, we could merge this first, and pull update for 859.
I think this might be the root cause for #858 . At least it is a hint for my issue for what I can investigate. Out of bound read on the controller will be a overflow on the host. Tnx!
[hathach/tinyusb] New branch created: mindmotion\-followup
Describe the PR
- add OPT_MCU_MM32F327X
- move dcd_mm32f into mindmotion folder
#859 also modify the same driver, do you see any conflict. If not, we could merge this first, and pull update for 859.
There are some conflicts between this branch and #859. I did some refactoring to add dcd_edpt_xfer_fifo(), so there are conflicts. I will fix up these conflicts after #859 is merged.
Putting the bit field ordering at the beginning and the end of a structure declaration is fine for me.
BTW: I'm not sure if the bit field order is really important on every bit field. I did not haven't a deeper look on it, if it is a local used bit field. I guess it is only important, if the bit field is transferred over USB or if it is mapped over a RAM/HW region and not if it is used as a local status variable.
Yes, that is possible. The only exception, which comes to my mind at the moment, is that it could be a negative speed impact if accessing packed structures. Maybe we should check if the packed attribute is really required on all structs here ?
we only group these packed structure that are consecutive to each other in tusb_types.h i.e we only group them together instead of declaring for each struct. So it is literally the same.
This only need to apply to those in usb specs, local vaiable should have no problem. However, the default right is the same as the default of gcc. So I think we are good to start with.
#859 also modify the same driver, do you see any conflict. If not, we could merge this first, and pull update for 859.
There are some conflicts between this branch and #859. I did some refactoring to add dcd_edpt_xfer_fifo(), so there are conflicts. I will fix up these conflicts after #859 is merged.
Thanks, let's wait for 859 a bit, if the issue with weak function isn't resolved anytime soon, we could merge this first instead
Ok, I understand that. The advantage of this would be, that the compiler does not generate code if the callback is defined as NULL.
It is not convenience to force user to manually enable this one by one. Also the modification is too much to support and maintain. There are dozens more used by other class driver and host stack in the future. For ccrx, without weak support, I guess this is good compromise.
Of course, the easiest way would be to leave the weak macro for the CCRX port undefined. It would the be required by the user to implement all the functions which have the weak attribute in the GCC port. But I can not estimate does this have any impact on the execution speed (means calling empty callback function all the time) ?
If I see a negative impact on the project I'm using tinyUSB, then I might make a local change to overcome the problem for the time being.
Of course, the easiest way would be to leave the weak macro for the CCRX port undefined. It would the be required by the user to implement all the functions which have the weak attribute in the GCC port. But I can not estimate does this have any impact on the execution speed (means calling empty callback function all the time) ?
If I see a negative impact on the project I'm using tinyUSB, then I might make a local change to overcome the problem for the time being.
It should be tha...
If the compiler does not support a weak feature, why not call the default inline callback function specified by the compiler argument? I tried that the following experiment.
#include <stdio.h>
static inline void default_cb(void){}
int main(void) {
if (hello) {
printf("ok\n");
hello();
}
return 0;
}
I compiled the above file which name is hello.c with following command.
`ccrx.exe -change_message=information -output=src -isa=rxv2 -inline -de...
Describe the PR
More buttons = more better
This pull request implements a configuration option to switch between the current 16 buttons and 32, with the current 16 buttons being the default value.
Adding "#define CFG_TUD_MAX_BUTTONS 32" to tusb_config.h enables the extra 16 buttons.
Additional context
While trying to map a real life RC transmitter to a controller that can easily integrate with flight sims I quickly run out of buttons to map all my 3 position switch...
@kkitayam It could be a possible solution, but I guess @hathach has to answer that. In the mean time I can leave with the solution to leave the weak macro empty.
[hathach/tinyusb] New branch created: fix\-rp2040\-host\-transferred\-bytes
Describe the PR
Fix transferred bytes, should be masked after buf_sel adjusted (E4). The E4 walkaround still has issue with ep size = 8 bytes in Fullspeed mode.
Note: I think it is better to just implement the double buffering to get in sync with hw (will do in later PR).
inline function may not work with
if (weak_func) weak_func()
Since it does not emit symbol. Also the static inline require function must be included by the class driver, and which means all the weak function must be implemented in header file of tusb_config.h (or one of the file it includes). Which can grow very unpleasantly. Therefore I still prefer to force the strong symbol on CCRX, eventually when they support weak symbol, we can easily flip the TU_ATTR_WEAK to support ...
nice, I thought 16 is already enough, apparently not. To simply thing, we should just update the number of buttons to 32 entirely without the need of CFG_TUD_MAX_BUTTONS. Would you mind updating the PR to just use 32 buttons to replace existing 16 buttons. More is better !!!
off by one, also incorrect Button 16 in comment for typo
I have no problems making 32 buttons the only option.
The reason I went the long way around was that I though people might be bothered by the increase in size of the joystick report.
I also updated the GAMEPAD_BUTTON_ entries and comments. GAMEPAD_BUTTON_15 is now GHAMEPAD_BUTTON_16 to match how windows and most game reference the buttons.
I have no problems making 32 buttons the only option.
The reason I went the long way around was that I though people might be bothered by the increase in size of the joystick report.
Yeah, but don't worry, people shouldn't be affected if using the helper API. Those that uses the raw API should know what to do :)
I also updated the GAMEPAD_BUTTON_ entries and comments. GAMEPAD_BUTTON_15 is now GHAMEPAD_BUTTON_16 to match how windows and most game reference the buttons.
I am...
@hathach I considered starting it at 0, but since the other buttons have symbolic names (A, B, SELECT, START, etc) I think it makes more sense to match how they are displayed to the end user.
I understood @hathach's opinion, and I agree with to force the strong symbol on CCRX.
If application developers are concerned about calling empty functions on CCRX, they can achieve the trick I suggested by defining a static inline function in the application's tusb_config.h. Maybe.
out of bound in proc_read10_cmd
p_cbw and p_csw is receive from other usb device
static void proc_read10_cmd(uint8_t rhport, mscd_interface_t* p_msc)
{
msc_cbw_t const * p_cbw = &p_msc->cbw;
msc_csw_t * p_csw = &p_msc->csw;
uint16_t const block_cnt = rdwr10_get_blockcount(p_cbw->command);
uint16_t const block_sz = p_cbw->total_bytes / block_cnt;
// Adjust lba with transferred bytes
uint32_t const lba = rdwr10_get_lba(p_cbw->command) + (p_msc->xfe...
thanks, that makes sense for sure. Though I still like to hear from another user on another platform (Linux) as well. Let just wait for his input for a day or two.
Do you plan to submit a PR for these?
No problem.
At least one app in Linux does 0-31 :) I don't know any actual games to test on the pi though.

Set Up
Compile the example: make DEBUG=1 BOARD=stm32f411disco all
- Ubuntu 20.04.2 LTS
- STM32F411DISCO
- master (1b8473902fb0e808c32183f306938accc9ce0d5)
- Firmware e.g examples/device/net_lwip_webserver
Describe The Bug
I reach the following assert when connecting to my host pc over usb:
usbd_edpt_xfer (rhport=rhport@entry=0 '\000', ep_addr=129 '\201', buffer=buffer@entry=0x2000001c "\001", total_bytes=)
at /home/bkamath/.dev/fb/tinyusb/src...
Found issue #289 after posting this. It (along with a few of the MRs) have a fair amount of discussion, I'm not positive this isn't a duplicate.
sorry, I have no time for this
Then I would appreciate it if you knock it off with the unhelpful // bug!!! and // vuln!!! annotations in the source snippets when as you find them.
I have updated the gamepad helper with uint32_t for buttons, also do a rebase since mater has some changes.
I just did a quick check, and Steam controller setting seems to start from 0, and is spot-on with Button South. Now I am more lean toward starting from 0.

@hathach Some note about the missing weak attribute on CCRX. I tried to cleanup the code and removing my solution of the weak functionality. While doing so I found the following code situation:
If I implement an empty tud_descriptor_device_qualifier_cb what would the return value be ? I think it should be NULL, but this is maybe a problem because the return value is actually ...
Should I go ahead and change them to be 0 based, or do you feel like we should wait a bit more? I really don't have a strong opinion on this one and would be ok with either.
I have updated the gamepad helper with uint32_t for buttons, also do a rebase since mater has some changes (push to your fork). Please pull first if you want to make more changes.
Good catch. I had missed those.
Should I go ahead and change them to be 0 based, or do you feel like we should wait a bit more? I really don't have a strong opinion on this one and would be ok with either.
Yes, please do, also please remove the "Note: button number from 1 on host OS" as well. I think we will just merge it starting with Button0.
Perfect, I actually have a final tweak to have all button number to make it consistency. The std naming for button (x,y,a,b) is now defined as macro alias.
whats missing on this PR? I have a device that will end up using this driver, and it would be convenient for me to have it merged, can i help in any way?
just return NULL TU_ASSERT(desc_qualifier); already take care of that and return if it is NULL.
Hi, at the moment this PR is tested on bulk transfer but other types of transfer remain untested (should work)
I've done some more work about fifo support but also remain untested.
Hi, at the moment this PR is tested on bulk transfer but other types of transfer remain untested (should work)
I've done some more work about fifo support but also remain untested.
Getting cdc_msc and hid_composite running is good enough for PR to merge. The rest can be done as follow up PRs. It is not easy to get everything right for the 1st pr.
[hathach/tinyusb] New branch created: host\-update
Describe the PR
- remove hcd_edpt_busy(), will be replaced by usbh_edpt_busy()
- remove hcd_edpt_stalled()
- move hcd class driver API into its own usbh_classdriver.h
I have a device that will end up using this driver, and it would be convenient for me to have it merged, can i help in any way?
I'll push all works, could you test BSP integration and build with gcc ? Since I'm developing with IAR and my own BSP layer.
Hi, I used CDC_MSC modification to make a DEMO that read FLASH chip. However, no matter how this FAT table is modified, it will only display 127K at most on PC. If formatted, it will prompt failure.
Sorry,
I did not understand if a version of net_lwip_webserver was made with Freertos
Thank you
Gionatha
A lot of users of Raspberry Pi Pico SDK1.2.0 tried to build the TinyUSB examples directly from within the example directories in the TinyUSB submodule, which failed without a helpful error message
This change changes the builds to include family_support.cmake and have that include the /family.camke so that it can produce a useful error message (this is cleaner anyway).
I can build with GCC, but the only board i have with this device is custom, so Ill have to use my own BSP as well
Sorry,
I did not understand if a version of net_lwip_webserver was made with Freertos
Thank you
Gionatha
Hi Gionatha,
Esp32 MCUs are running esp-idf.
Freertos is a submodule of esp-idf.
Hence this operating system is the default operating system for all esp32 projects.
Hi Gionatha,
Esp32 MCUs are running esp-idf.
Freertos is a submodule of esp-idf.
Hence this operating system is the default operating system for all esp32 projects.
Ok, I use nxp development board.
Could I see the main project file and the library configuration files to see if they can help me solve my problem?
I probably have problems with assigning lwip library functions to FreeRTOS tasks
[hathach/tinyusb] New branch created: host\-rp2040\-double\-buffer
Describe the PR
This PR implements double buffered for RP2040, rework/refactor the existing quite a log
- we don't have to deal with RP2040-E4 hardware our of synce
- faster transfer for control and bulk
- Should fix https://github.com/raspberrypi/pico-sdk/issues/442 with logitech universal receiver (8-byte control in Fullspeed) and wired keyboard with 8byte control in Lowspeed
- Lots of internal rp2040 usb renaming
Since rp2040_usb is also used by device, but tested on device i...
seem like it has an issue with esp32s2, give me a bit of time, I will check it out and try to fix the build.
Got it to compile fine on gcc, just needed to swap some macros that are deprecated in the sam cmsis, i guess it doesnt error in IAR, as for actually testing in hardware I can't do it just yet, I'll Pr the changes in your branch
@hathach Removed the missing weak attribute work around and merged again from current master
Today I tested MSC also works, maybe this weekend I'll test more examples.
Sorry for all the force pushes, kept overlooking somethings that made the build check fail :sweat_smile:
Signed-off-by: Rafael Silva
Describe the PR
Implementation of a DCD driver for the SAM3U.
Additional context
The SAM3U seems to have a similar USB core to the SAMx7x family, for which support is being added in #693, but the register map seems to be completely different.
That said, thanks to that it should be easier to port.
- [ ] Port dcd based on SAM7X;
- [ ] Successful build;
- [ ] Working examples (cdc_msc, hid_composite);
Thanks a lot for fixing the example and for porting! The audio driver was under heavy development and we only had our custom boards so we could not re-test all examples. Can this issue be closed?
yup, let close this, can be opened another one if needed.
Hi Gionatha,
Esp32 MCUs are running esp-idf.
Freertos is a submodule of esp-idf.
Hence this operating system is the default operating system for all esp32 projects.Ok, I use nxp development board.
Could I see the main project file and the library configuration files to see if they can help me solve my problem?
I probably have problems with assigning lwip library functions to FreeRTOS tasks
Hi Gionatha,
please check the two things:
- CMakeFiles
- sdkco...
Superb !! without the weak macros, thing is much cleaner. I think we are very closed to the merge. I only have a few questions. Will try to setup my board to test this soon enough.
please remove all the platform dependent __Tx36V5_Maincard__
can it possible that you just enable configSUPPORT_STATIC_ALLOCATION, the dynamic API can still be used with this option turned on.
does rx mcu requires the usb buffer to be 4 byte aligned, if not this can be ignored
do we really need to disable the whole irq, can we just disable the USB IRQ for this.
if it is the same controller, it should be merged together, instead of having 2 different dcds. I have done something similar even across family line for LPC, iMXRT https://github.com/hathach/tinyusb/blob/master/src/portable/nxp/transdimension/dcd_transdimension.c#L30
It is more work initially, but much less work later on when maintaining and fixing bugs.
there is actually an SAM7X which is different mcu, https://www.microchip.com/developmenttools/ProductDetails/PartNO/AT91SAM7X-EK
Maybe call it SAMX7X, I am not good for naming, any other suggestion is welcome.
Yes SAMX7X works... I can't figurer out something better neither ๐
Maybe, I just copied ASF's code.
This is the style of the C99 standard. CCRX supports the C99 standard by specifying -lang=c99 as a command line argument. Since TinyUSB implicitly requires c99, I think CCRX should also have this option.
@Wini-Buh
If you don't mind, could you add your copyright notice at dcd_usba.c.
yeah c99 is really old now, it should be enabled to build with.
that is quite a lot, we don't disconnect/connect often, but that is a bit weird to go into critical section for this. But let just leave it as it is. We can revisit it later.
Thank you for your PRs, sorry for late response, have been busy testing the double buffered and other works. I made the push to set TOP for an example to pass build with esp32sx. Will merge when ci passed.
As I understand it, there is no need for alignment if DMA is not used. And the current implementation does not use DMA.
If using DMA, the buffer must be 2 bytes aligned.
Thank you for your PRs, sorry for late response, have been busy testing the double buffered and other works. I made the push to set TOP for an example to pass build with esp32sx. Will merge when ci passed.
no worries; i figured that TOP was the problem, but hadn't got as far as fixing it either... i would have set TOP in the family.cmake for the esp32x instead though
Don't worry. I found the solution that also works with GCC, so the check which toolchain is used is no longer required. The problem with this struct definition and CCRX is, that one of the struct member is defined as an union which includes some bit fields (that could be an error of the CCRX toolchain ? ).
BTW: I already use C99 language option.
RX MCU does not need an alignment on this. It was introduced, because there was an error in dcd_usba.c, which is corrected. On my test code the _usbd_ctrl_buf buffer started on an odd address and with the error in dcd_usba.c the transfer over an endpoint was faulty. So this fix is no longer required (as long as no DMA transfer is supported).
Yeah, that is a better place to set TOP. Though I just tried to it fixed for not, will have to update/write the cmake for esp32sx anyway later on.
It is surprised that ccrx has align pragma for function but not variable. Anyway there is several other places that may requires alignment especially endpoint buffer in each class driver. Therefore, maybe we revert this changes for now, and will revisit these later when doing DMA. SInce doing this alone is not enough anyway.
Like i said it appears to be similar, but the registers are completely different
ups my bad, had no knowledge of sam7x being a thing, and didnt think to search.
I have to look further into it, the register map seems very different but it still might make sense to join them
yeah, I really prefer to join them if possible, or at least extract/abstract transfer handling into common API.
not a problem at all. I like your naming more, but unfortunately, avoiding confusion has more priority :)
@HiFiPhile let me know when you think the PR is ready for testing, or just mark it as Ready. I will pull out my same71 explained to test with.
thanks for the issue, I also encouter the ASSERT with 0x81 endpoint, however, it seems to be "normal" since currently the net driver doesn't check the busy state of the notification endpoint and can send one while previous one doesn't received by host yet. This will be fixed later but in general it does affect the example as this also appear on other working MCUs as well.
After reading SAM3U's manual, it seems they are very similar in functionality.
But there are too much differences in register map, I'm afraid we need to spam #ifdef in order to merge them.
After reading SAM3U's manual, it seems they are very similar in functionality.
But there are too much differences in register map, I'm afraid we need to spam
#ifdefin order to merge them.
It is doable with by extracting function to common API and/or some other works. There is no rush to support SAM3U, we do it little by little.
Thanks for confirming. What would be the correct way to handle this at the application layer if I wanted to work around it? Do I need to make it more into a queue + state machine? Or can I just not send if the endpoint is busy (will the host eventually retry)?
Happy to make a PR if I can understand the problem well enough.
The reason I added this is because I actually need a usb driver for the sam3u (as well as the sams70), so im planning on working on this
The reason I added this is because I actually need a usb driver for the sam3u (as well as the sams70), so im planning on working on this
If you feel adding new dcd is quicker, feel free to do so in this PR to test with your board. Once it is ready, I could help with the merging.
Hi @hathach
I have added support SAML21
depends on https://github.com/hathach/microchip_driver/pull/6
Thanks
I got some problem testing HID example, seems like HID descriptor was not sent correctly ?
USBD init
HID 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 ... OK
USBD Resume
USBD Xfer Complete on EP 80 with 18 bytes
Queue EP 00 with 0 bytes ... OK
USBD Resume
USBD Xfer Complete on EP 00 with 0 bytes
USBD Bus Reset : Full Speed
USBD Resume
USBD Setup Received 00 05 01 00 00 00 00 00
Set A...
There is also tons of Resume signal without the Suspend before that. I will help to troubleshoot whenever I could
What's strange is the desc_hid_report, first 3* 64 bytes packets are good but last 47 bytes is wrong with Bushound:
Device Length Phase Data Description Delta Cmd.Phase.Ofs(rep)
------ -------- ----- -------------------------------------------------- ---------------- ----- ------------------
48.0 CTL 81 06 00 22 00 00 2f 01 GET DESCRIPTOR 9us 10.1.0
48....
I'm wondering if it's some side effect when Segger RTT access DTCM trying to search _SEGGER_RTT buffer.
No longer to reproduce the issue after fixed RTT address manually:
__jlinkExecCommand(SetRTTAddr 0x20400000);
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.
The changes look great. Have you tried some of the stock examples to see if they work out, especially cdc_msc and hid_composite.
@zhangslice seem like your fork is out of sync with my master.
- The submodule is already existed as part of the previous PR here https://github.com/hathach/tinyusb/blob/master/.gitmodules#L124
- the dcd_mm32f327x_otg.c is also existed in https://github.com/hathach/tinyusb/tree/master/src/portable/mindmotion/mm32
Could you get your fork update with master, then rebase your PR.
Okay, I'll try again tomorrow after fork
------------------ย ๅๅง้ฎไปถย ------------------
ๅไปถไบบ: "hathach/tinyusb" @.>;
ๅ้ๆถ้ด:ย 2021ๅนด6ๆ16ๆฅ(ๆๆไธ) ๆไธ8:20
@.>;
@.@.>;
ไธป้ข:ย Re: [hathach/tinyusb] add mm32 dsp (#896)
@ha...
The changes look great. Have you tried some of the stock examples to see if they work out, especially
cdc_mscandhid_composite.
yes, I tried cdc_msc, work ok
The changes look great. Have you tried some of the stock examples to see if they work out, especially
cdc_mscandhid_composite.yes, I tried cdc_msc, work ok
Great, thanks for confirmation. Can you add the SAML21 family into the ci build right before saml22. https://github.com/hathach/tinyusb/blob/master/.github/workflows/build.yml#L52
I think you need to bump up the microchip submodule as well for CI to pass
Describe the PR
A clear and concise description of what this PR solve.
Additional context
If applicable, add any other context about the PR and/or screenshots here.
I reviewed the dfu_req_dnload_setup and do not see this as a bug, provided that the CFG_TUD_DFU_TRANSFER_BUFFER_SIZE is in the descriptor. For this case to happen, the host would have to non-compliant. I will add a check here so that if the host were to send a request too long the issue would be more easily traceable.
On review, I did discover that I do have a bug elsewhere:
static uint16_t dfu_req_upload(uint8_t rhport, tusb_control_request_t const * request, uint16_t block_num,...
The attack model is that there is a malicious USB device that will send malformed USB messages to our protocol stack๏ผ so we need to check the data recv from another USB device.
Yeah I am well aware of this issue. This will basically allow host purposely write/read memory in other section by overflowing current one. This can effective change the behavior by changing RAM contents. An famous example is Nintendo Switch https://youtu.be/67swnr1NCP4?t=195
I want to help to speed up the merge of this PR (has been going for a while), so that #874 can be merged, and also help testing with the net lwip example.
However, setting up the rn65n cloud kit (picked because it come with add-on board with usb connection) is a bit difficult to me since this is first time I worked with renesas mcu. Renes...
Thanks for the PR to add BSP for your board. Though the dcd is already added at location https://github.com/hathach/tinyusb/tree/master/src/portable/mindmotion/mm32 . I moved it into the src/portable/mindmotion/mm32 folder. To help pushing this PR, I will push the update myself.
Switching from CFG_TUSB_OS=OPT_OS_FREERTOS to CFG_TUSB_OS=OPT_OS_CUSTOM to use my own RTOS API integration file to overcome this issue
Switching from CFG_TUSB_OS=OPT_OS_FREERTOS to CFG_TUSB_OS=OPT_OS_CUSTOM to use my own RTOS API integration file to overcome this issue
I need to have deeper look at that. It seems to be a problem between the endian macros found in descriptor macro and the bit field definition in the tusb_desc_endpoint_t struct. Especially in the big endian configuration (in little endian configuration the code seems to work).
BTW: Sorry for the time delay, but at the moment I'm very busy at work. I hope to get it done this weekend
@hathach Maybe I could support you a little bit. I don't also like the FIT modules (I had to much negative experience with it, like with other similar technique from other vendors). Is there a board support package available for your board ? It would at least help you to speed up the clock programming for the first time.
BTW: Sorry for the time delay about this PR, but at the moment I'm very busy at work.
I have added makefile (family.mk and board.mk) to allow building the mb39 board, though It needs https://github.com/zhangslice/mm32sdk/pull/1 to be merged first to add the startup file for gcc.
@zhangslice I couldn't find a way to flash the board to test its functionality. My windows VM couldn't able to connect to the mcu using mm32-link. The led next to the link usb connection blinking forever. Any tips to connect and flash the board would be helpful.
. Is there a board support package available for your board ? It would at least help you to speed up the clock programming for the first time.
That would be great to have more help, here is link to my board from renesas site https://www.renesas.com/us/en/products/microcontrollers-microprocessors/rx-32-bit-perfo...
[hathach/tinyusb] New branch created: fix\-nrf\-control\-bulk\-race\-condition
Describe the PR
fix race condition with control since TASKS_EP0RCVOUT also require EsyDMA. Related issue
Describe the PR
This re-orders the order of two of the designators in a struct initializer to match the struct field declaration order to avoid compiler errors.
Additional context
I'm compiling for an Arm Cortex-M0, and my compiler threw an error because the designator order was different in the initializer than in the struct declaration.
Set Up
- Archlinux, distro kernel 5.12.8,
- custom board with STM32H730 and USB PHY USB3343 (may provide schematics on request)
- TinyUSB version b34724215bea28ef93fd80ed9c2e4ddc87874093 with synopsys hotfix #496
Firmware
- based on RTOS (modified Argon)
- osal implemented and queue passes events to tud_task
EPs
uint8_t const desc_h...
I have fixed ci build, but couldn't push to your fork to update PR. Could you give me the write permission to your fork, so that we could wrap this PR.
The.ld file is added in DSP, and the.s file is in my branch. All products with ARM kernel can use JLink. The on-board debugger we brought with us also provides a JLink socket. I have sent you the schematic diagram of the board for you to check, and it is marked accordingly. You don't need to use our own upper computer software. If you want to use it, you need to install the driver and there are instructions on the official website.
------------------ย ๅๅง้ฎไปถย ------------------
ๅไปถไบบ: ...
I have fixed ci build, but couldn't push to your fork to update PR. Could you give me the write permission to your fork, so that we could wrap this PR.
I have added as a contributor
@zhangslice I don't see the startup file (.S) for gcc in your PR. There is also other typo (incorrect file name which will failed to compile on case-sensitive OS like Linux). Can you check out the PR and merge it to your sdk https://github.com/zhangslice/mm32sdk/pull/1
For using Jlink, I also like to use it as well, however, the supported list from jlink does not cover your MM32F327 yet https://www.segger.com/downloads/supported-devices.php?m=MindMotion , which device should I use to flash...
Everything look great, thank you very much for your PR.
I've reproduced this on the SAMD21 as well, and I can confirm the patch of checking ep_out resolves the issue (at least for us).
@hathach
I might be help you. I have a RX65N target board.
I had bought it before gr_citrus in order to study RX MCU. Actually, I had tried to implement DCD on this board, but I failed. There were many transaction errors. I don't know if the lack of external XTALs is to blame, or if my wiring for the USB connector is to blame.
[hathach/tinyusb] New branch created: add\-rx65n\-board
@hathach
I might be help you. I have a RX65N target board.I had bought it before gr_citrus in order to study RX MCU. Actually, I had tried to implement DCD on this board, but I failed. There were many transaction errors. I don't know if the lack of external XTALs is to blame, or if my wiring for the USB connector is to blam...
Just FYI for the next unlucky dev:
I've also unsuccessfully tried to get USB working on this board, apparently the board needs to be modified first. (From the User Manual DocID027676 Rev 3):


I took out my 5 years old LPC4357 board to have some fun with USB & SGPIO...
I saw there are some TODO, It seems like ISO transfer is not supported yet ?
PS. I measured a raw bulk out throughput of 14MB/s maybe due to slow Flash access time.
I had used Renesas Flash Programmer GUI on Windows. I've never used the CUI. And, I am using JLink.
When using the JLink, the following pin connections can be used.
- short EJ2 jumper header.
- short EMLE pin (P03) and 3V3(VCC)
| Function | J1 pin header | RX65N pin name | JLink pin number |
|---|---|---|---|
| 3V3 | 14 | VCC | ... |
Describe the PR
-
Add bracket to switch case, fix warning
switch transfer of control bypasses initialization of xxx -
Put
tu_desc_subtype()in#if CFG_TUD_AUDIO_ENABLE_ENCODING || CFG_TUD_AUDIO_ENABLE_DECODING, fix unused function.
Seems Diff is a little bugged...
[hathach/tinyusb] New branch created: fix\-midi
Describe the PR
Fix #843 , add check to prevent issue when calling midi API when device is not enumerated. Which could cause incorrectly submit transfer to endpoint 0x00 (when not initialized).
Thanks for confirming, just fixed this, I kind of forgot about this somehow. My memory is fading :sweat:
Thanks @kkitayam to be honest, I would expect it should just work out of the box, They are all tools from renesas and it would make it easier for user that want to test out the board as well, I will give a few more try and then back to jlink if it doesn't work out.
No problem at all, thanks for the quick fix. :)
yeah, it is not yet supported. I don't actually implement any ISO transfer myself since It has no application/audio driver to test with until recently. I have a bad habit of not writing code that aren't run yet.
PS. I measured a raw bulk out throughput of 14MB/s maybe due to slow Flash access time.
How did you carry out the test ? I haven't done much of speed optimization just yet.
Just FYI for the next unlucky dev:
I've also unsuccessfully tried to get USB working on this board, apparently the board needs to be modified first. (From the User Manual DocID027676 Rev 3):
I remembered seeing something like this, hmm, I think I tried it out one way or another. Not entirely sure though, my memory isn't good anymore. Have you finally got it working .
The existing code still works without DTR. However due to no flow control, it wouldn't know if there is any terminal connected and therefore have no way to tell when the fifo will be drained. Therefore the fifo mode is set to overwritable.
There is no clues if this is an tinyusb issue. There is too many custom changes from your setup. And there is no way for me to understand and track down the issue. If you could reproduce the issue with
- one of supported board
- one of example with slight modification
Then I could possible help you with narrow it down.
How did you carry out the test ? I haven't done much of speed optimization just yet.
Just a simple test, running cdc example, I measured the elapsed time of 100*4096b packets.
var port = new SerialPort();
port.PortName = "COM9";
port.Open();
byte[] data = new byte[4096];
for (var i = 0; i < 4096; i++)
{
unchecked
{
data[i] = (byte)i;
}...
what is your CFG_TUD_CDC_RX_BUFSIZE/CFG_TUD_CDC_TX_BUFSIZE, as always, since the transfer need to wait for tud_task() called in main loop, and low buffer size can cause slow throughput.
also thank @kaysievers for raising and posting patch for this.
CFG_TUD_CDC_RX_BUFSIZE/CFG_TUD_CDC_TX_BUFSIZE
It's 512 as default.
With 1024 I got 21MB/s and 27MB/s for 2048. If I remove tu_fifo_write_n(&p_cdc->rx_ff, &p_cdc->epout_buf, xferred_bytes); in cdcd_xfer_cb I got 2MB/s quicker.
I haven't done much of speed optimization just yet.
Seems the throughput is already good (a tud_task() call while idle still need ~250 cycles).
No, it doesn't work for me either with or without these changes. I'll poke around more with a debugger, and get back to you if I have something.
For ISO it seems there is a catch in queue management:
For ISO, when a dTD is retired, the next dTD is primed for the next frame. For
continuous (micro) frame to (micro) frame operation the DCD should ensure that the dTD
linked-list is out ahead of the device controller by at least two (micro) frames.
Actually in audio_device we finish the current one before schedule the next one.
@hathach I had a look at the documentation of your board. Here are some hints (maybe more or less useful):
- The onboard E2 Lite debugger can only use the FINE interface for debugging/programming, JTAG is not supported
- For the board there is board description file available, that should lower the entry level to get the board working
I would suggest to use the board description file and the smart configurator to setup the clock system, because this part is sometimes tricky and the gr...
Describe the PR
This simply fixes the typo of the configuration define CFG_TUH_ENUMERATION_BUFSZIE to CFG_TUH_ENUMERATION_BUFSIZE in a backwards compatible way and adds a warning about fixing it.
I'm not sure if you care about such backwards compatibility, since TinyUSB ist still at v0.x. I can remove it if you want.
no need for backward compatible with host at the moment, since it is not used much. Please just replace the typo
No, it doesn't work for me either with or without these changes. I'll poke around more with a debugger, and get back to you if I have something.
I think st sdk usb example works with the board, so I guess the hw is fine. Though again my memory is not good, but it is worth for you to check it out.
yeah,like said before, these dcd is capable of queuing multiple transfers at once, however, writing usbd in such a way is not portable. This applies to other transfer as well. We can come back to this later on when it become an issue.
Is your feature request related to a problem? Please describe.
ISO transfer and Audio driver is supported (for some mcus), maybe the next thing is getting video class implemented.
thank you for your PR. Unsurprisingly, I still made tons of typo with the word szie :D
@Wini-Buh thanks, I will try to use the E2 studio to generate some clock, though I include bunch of other FIT files. One of the issue is E2 studio on Linux does not support RX at all. VM is ok, but it is a bit annoying. I will give it more try this week.
@hathach
I pushed some commits into my branch. I have confirmed that the commits make board_led_write() and board_button_read() work fine on board_test example. But, board_uart_read() doesn't work.
And, I will try Renesas Flash Programmer CLI.
on the RP2040, after sending around 1000 characters from a (linux) host without DTR being asserted (characters which are being echoed back by the RP2040), the USB subsystem on the host locks up solidly for around 30 seconds before returning a 'try again' error message back to the user application. while this seems to be a problem with the host/linux, it would be good for the RP2040/tinyUSB to instead be configurable to ignore the state of DTR and just keep sending characters back to the h...
what is the issue with current implementation that you want to change ?
@kkitayam wow thank you, I am current switched to other works, but will test it out when possible.
And, I will try Renesas Flash Programmer CLI.
I was able to confirm the writing with rpi-cli by using following steps on Windows 10. I think that it works on Linux.
make BOARD=rx65n_cloud_kit
rx-elf-objcopy -O ihex _build\rx65n_cloud_kit\board_test.elf board_test.hex
rfp-cli -d RX65x -t e2l -if fine -fo id FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF -auth id FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF -a board_test.hex
rfp-cli had output following logs.
Renesas Flash Programmer CLI V1....
@kkitayam bravos, that is a great progress :+1: :+1:
at the moment, with RP2040+tinyUSB, if DTR is not asserted by the host (in my case a desktop PC running linux), the RP2040 stops sending characters to the host. it looks like tinyUSB attempts to buffer these characters. after approximately 1000 characters have been buffered a malfunction occurs. this scenario can be demonstrated with micropython running on a RP2040 (micropython uses tiny USB).
**what i would like to be able to do, is to configure tinyUSB so that it ignores the state of DTR...
at the moment, with RP2040+tinyUSB, if DTR is not asserted by the host (in my case a desktop PC running linux), the RP2040 stops sending characters to the host. it looks like tinyUSB attempts to buffer these characters. after approximately 1000 characters have been buffered a malfunction occurs. this scenario can be demonstrated with micropython running on a RP2040 (micropython uses tiny USB).
Have you tried to figured out why tinyusb stop sending data to host. Any log from stack ? It se...
the software engineer developing for the RP2040 is located in the UK, the other side of the world to where i am (in New Zealand). his perspective is that it works ok for him (win10, using teraterm as a terminal emulator) and he has no interest in testing for anything other than his own setup; he is a 'challenging' person to deal with. the source code will only become available to me once his code is 'released to production'.
hence my reproducing the behaviour with micropython, where the so...
Extend tud_vendor_n_write() to make a zero length transfer when buffer==NULL && bufsize==0, as discussed in #903.
I consider implementing this via a flag to maybe_transmit() the best solution:
tud_vendor_n_write()doesn't have access to neitherbuffernorbufsize, so it can't make the decision.- Implementing it completely in
tud_vendor_n_write()would mean duplicating some functionality ofmaybe_transmit()(but judging by your latest comment maybe that's what you prefe...
I see and understand your problem since you are not familiar with mcu. However for this issue to be addressed, and if you still want it to. Please update your 1st post to provide all the setup information with specific version of each software (mp, picosdk, tinyusb) and step to reproduce issue. Then change the label to Bug. Though since I don't often use mp, this will have huge delay for me to even try to reproduce it.
I did some test about this issue here. First I setup a new build variant with GCC in big endian order to check if the same problem occurs as with the CCRX. This was not successfully, build my test project with GCC in big endian order shows a problem in the tinyUSB sources with bitfields.
First the order of the bitfields is changed and second there is no possibility to change the ordering of the bitfields in GCC (at least I found no possibility). Every thing I tried (for example `#pragma ...
@zhangslice please pull and update the PR by continue to commit and push to pr here https://github.com/hathach/tinyusb/pull/897 instead of opening new PR for each change.
Sorry for the delay here. The code looks good to me. I don't have much time to test it at the moment because I am working on a different project. @kilograham do you have any thoughts?
Describe the PR
Addresses memory out of bounds access in dfu class, including dfu related one mentioned in #880.
Additional context
Adds TU_VERIFY to dfu internal buffer access from host.
Adds TU_ASSERT to dfu internal buffer access by application.
Sorry for the delay here. The code looks good to me. I don't have much time to test it at the moment because I am working on a different project. @kilograham do you have any thoughts?
No problem at all, I am busy with other works anyway. Note currently the double buffered is not fully operated (skip with device IN), but we could address this later. For now, anyone that could help with testing would be great.
I am getting these error when running the tinyusb submodule on windows 10. I am new to using submodules and I need some guidance on rectifying these issues.

are these files just missing in the submodule or should they be removed?
Describe the PR
Like audio class, CDC need DMA support in order to support high speed transfer.
Additional context
If applicable, add any other context about the PR and/or screenshots here.
It's not enough to just export the fifo, need a mechanism to call _prep_out_transaction.
I don't think exposing fifos is good idea. I don't have a specific suggestion for now, but we will need to spend more time to look at this later on.
In fact CDC streaming is needed by my company's project which restarted recently, following my tests last year.
For the short time expose the fifo fit my need, of cause we can make something better for example expose only fifo_info even add edpt_xfer_fifo support.
In fact CDC streaming is needed by my company's project which restarted recently, following my tests last year.
For the short time expose the fifo fit my need, of cause we can make something better for example expose only fifo_info even add edpt_xfer_fifo support.
It is easy to expose an API, but it is very hard to drop one. I would prefer to figure it all out first. I think for now, you could make an "hack" for your fork e.g dropping static in the function/variable in the cdc_dev...
Is your feature request related to a problem? Please describe.
Raw throughput of USB can be high but once you make some data copy the speed will drop significantly. Currently there is no way to skip fifo & buffer in CDC class:
USB HW Buffer ==> ep_out_buf ==> rx_ff ==> User app
Besides DMA is not supported.
We had some discussions on this subject, for example expose the fifo or add xfer_fifo support.
Describe the solution you'd like
Sort out a solution to make CDC class ...
I've opened a new issue to discuss #920 .
This is already asked, but can you put up your board & setup and how you test the throughput and its result. This allow others to join and try with their own setup for comparison.
I've done some tests:
- MCU LPC4357 @ 204MHz
- Host Windows 10 x64 20H2
- Toolchain IAR 9.10.2, High balanced optimization
- Code
examples\device\cdc_dual_ports, except using simplified cdc_task() fromexamples\device\cdc_msc - Test script ser_test.py.txt
| Config | Thro...
@HiFiPhile which one?
Last month I saw you had some discussion about DMA and CDC, have you sorted it out ?
@HiFiPhile which one?
Last month I saw you had some discussion about DMA and CDC, have you sorted it out ?
No.
I wrote a "dma pump" to allocate DMA channels and use on request of heterogeneous consumers. But performance were not as good as integrating dma in peripheral's functions. Probably working a bit more on that route would bring good results, but it is too much work to circumvent the lack of control over buffers. The easiest path would be to be able to supply your own b...
@HiFiPhile wow, that is a very great detail, current queuing only 1 transfer per endpoint can also limit the actual throughput. Though expanding it can increase code complexity since there is more mcu that does not support that than one does. But definitely what we could take a look a.
Though expanding it can increase code complexity since there is more mcu that does not support that than one does. But definitely what we could take a look.
Yes I agree with you, currently 30MB/s is close to the limit, I think it's easier to focus on reduce CPU utilisation.
I'll try to add edpt_xfer_fifo support for CDC class and have few questions @hathach , @PanRe :
For OUT xfer:
Is the caller's responsibility to check free space (DCD just do the queue) ?
For IN xfer:
Is the cal...
HI,
As for the OUT transfer, i would say since CDC is a supposed to be a reliable connection (Bulk EP), i would set the FIFO to be non-overwriteable, check within the CDC driver if the received frame can be stored within the FIFO entirely and if not don't acknowledge the successful reception such that the host resends the frame again (hoping that later on there will be space available). Within UAC2, i selected the FIFO to be overwriteable and every frame gets acknowledged. This, however, cor...
This, however, corresponds to the nature of iso streams. So i would say the caller (i guess you mean the end user)
Sorry it's not very clear, I mean between class driver and dcd edpt_xfer_fifo implementation. Seems like class drivers check if everything ok before call edpt_xfer_fifo but I'm not sure...
For IN transfers, i am currently not sure what total_bytes
I mean the argument of edpt_xfer_fifo
Ah ok. Yes i would say it is the class drivers responsibility to check everything and the DCD only queues the ordered number of bytes given by total_bytes. This is the same as the linear buffer functions dcd_edpt_xfer() does. I always would restrict to total_bytes and never send more... Since it is a FIFO, there is a chance that the number of bytes in the FIFO is bigger at the time when the transmit gets executed compared to the point in time where the class driver scheduled the transm...
Maybe tu_fifo_remaining shoud take account if the fifo is overwritable.
Currently there is a bug in CDC when DTR bit is not set. FIFO is set to overwritable in this case, but since tu_fifo_remaining is checked before the transfer, no transfer is queued.
Describe the PR
Update some settings to run examples. I confirmed board_test and msc_cdc example work fine.
Additional context
I tested the patch on RX65N-Target-Board. The board is the same as main board of [RX65N-Cloud-Kit](https://www.renesas.com/us/en/products/microcontrollers-microprocessors/rx-32-bit-performance-effi...
During Adafruit Bootloader compilation, I spotted bellow error which do not allow me build project.
inlined from 'hfclk_running' at lib/tinyusb/src/portable/nordic/nrf5x/dcd_nrf5x.c:785:13:
lib/tinyusb/src/portable/nordic/nrf5x/dcd_nrf5x.c:792:31: error: 'is_running' may be used uninitialized [-Werror=maybe-uninitialized]
792 | return (is_running ? true : false);
| ~~~~~~~~~~~~~~~~~~~^~~~~~~~
Describe the PR
A clear and concise description ...
I've add cdc & dcd_transmission xfer_fifo support and updated the chart, result seems pretty good.
is this just a git feed or intended for discussion/questions about tinyusb?
Discussions and questions as well
Superb!! Thank you very much, will test this out today
I added a commit for flash. At first I only checked it with JLink.
rpi-cli sometimes report the following error, but after a few tries it succeeds.
[Error] E3000201: Cannot find the specified tool.
Just a reminder, after programming, the RX65N reset will not be released unless EJ2 is shorted.
Describe the PR
Various improvements in order to improve CDC efficiency.
Test result can be found in https://github.com/hathach/tinyusb/issues/920, which shows a great increment in throughput and
and reduce execution time.
- Add xfer_fifo support for CDC and dcd_transdimension
- Add functions to support direct (DMA) fifo transfer
tud_cdc_rx_wanted_cbis still WIP since can't be done without accessing underlying fifo struct members
Additional context
Linear buffer is...
superb !! Thank you very much. All the examples seems to work great on rx65n board including cdc_msc, hid_composite, net_lwip, midi_test.
I added a commit for
flash. At first I only checked it with JLink.
rpi-clisometimes report the following error, but after a few tries it succeeds.[Error] E4000004: A framing error occurred while receiving data. (BFW: 0354)Just a reminder, after programming, the RX65N reset will not be released unless EJ2 is shorted.
Yeah, thank, rpi-cli does has issue but not very often. It requires me to manually insert header to enter debug mode when flashing, th...
Describe the PR
This PR add support for Rensas RX65N cloud kit board, rename bsp from rx63n to simply rx. Huge thank to @kkitayam to sort out most of the issue. Most examples has been tested and working including: msc_cdc, hid_composite, net_lwip_webserver, midi_test
Describe the PR
Minor house keeping:
- merge saml21 + saml22 = saml2x
- comment out esp32s3 build in ci due to lack of USB0 define in IDF linker
- use the new bug form template
I have double checked again with all of device examples: cdc_msc, hid_composite, net_lwip_webserver, webusb, midi_test. Everything seems working perfectly. It is good for a merge. Thank you very much for reviewing the changes. Should there be any issue, it could be fixed as followup pr.
Hello
any chance to get the usb host wifi support for few dedicated wifi dongle to support B/G/N and ac, or Wifi 6 speed support and better ...
Keep going
best Regards
Jp
I much prefer jlink, btw, how would you add jlink to the rx65n target board. I may need it when doing doing more extensive work. It is not very clear in the board user manual.
@hathach
Yeah, the board user manual has no information regarding JLink. But, since both JLink and RX family are compatible with the JTAG standard, we can refer the pin connections regarding JTAG.
I have checked JTAG connections for schematics and [JLink connector](https://www.segger.com/products/debug-probes/...
Describe the PR
Improve host hid driver and example
- change usbh open driver to have max_len and return driver len
- force boot protocol for keyboard/mouse
- update hid host behavior for default boot interface
should now fix (hopefully) https://github.com/raspberrypi/pico-sdk/issues/442
@kkitayam superb !! thank you very much again, this is really useful information. I totally need this for later working with it.Thank you again. Your board to be the same to my rx65n target board (part of the cloud kit). I think it is better to just name it rx65n target board instead of cloud kit, since more people will have the target board.
Note: reason I order more expensive cloud kit because it has the daughter board with USB connector, since I have no idea if a simple jumper to usb b...
I got rid of RTOS.
CDC works normally. (ar at least some data are comming into device, LEDs are counting in binary). See cdc_task below
So i'd consider HW being OK. I do not have any of supported board at hand.
static void cdc_task(void) {
uint8_t itf;
static unsigned int cnt = 0;
for (itf = 0; itf < CFG_TUD_CDC itf++) {
// connected() check for DTR bit
// Most but not all terminal client set this when making connection
// if ( tud_cdc_n_connected(itf) )
{
...
With python-libusb1 library, issue seems to be non-existent. I'll try to compare behavior of python-pyusb and python-libusb1.
The issue seems to be the stack's vendor driver, currently it doesn't guard against race condition as cdc. I haven't updated the vendor driver once introducing the usbd_edpt_claim() for race protection. I actually have an plan to abstract these to stream/buffered endpoints API for driver and haven't got time to do so.
https://github.com/hathach/tinyusb/blob/master/src/class/vendor/vendor_device.c#L109
https://github.com/hathach/tinyusb/blob/master/src/class/cdc/cdc_device.c#L83
@PanRe Could you take a look if it's ok for you ?
[hathach/tinyusb] New branch created: update\-rx65n\-bsp
Describe the PR
- rename rx65n cloud kit to target
- adding note for adding jlink support for rx65n_target board
Thanks to @kkitayam for helpful tip for adding jlink to rx65n target board.
[hathach/tinyusb] New branch created: poison\-obsolete\-callback
Describe the PR
Add poisoned list (only gcc) for renamed callbacks, so that it make it easier to spot and fix the issue. Otherwise it can be under radar with the only warning is function not used. Original idea comes from https://github.com/hathach/tinyusb/discussions/921
Put to tusb_compiler.h since gcc seem to be the only compiler to support this, update/expand/refactor later on when needed.
Operating System
Windows 10
Board
Core4357
Firmware
examples\device\uac2_headset
What happened ?
Playing with uac2_headset I found there are output samples in the buffer, but mic input is always silence.
Initially there are IN xfer, but as soon as OUT intf is opened, IN xfer stops.
00> AUDIO xfer callback
00> Queue EP 81 with 0 bytes ... OK
00> USBD Xfer Complete on EP 81 with 0 bytes
00> AUDIO xfer callback
00> Queue EP 81 with 0 bytes ... OK
00> ...
The diff is a bit rugged yes, but as far as i see it you only added the brakets and changed some pointer definitions. It is ok from my side i guess, i did not conduct any tests. I am a bit puzzeled why IAR complains about pointers here while gcc does not... :D
I am a bit puzzled how this come to happen, but before digging deep into the code a few questions:
- Did you use the fix #849?
- Did you try disabling the debug messages? In my setup, streaming does not work at all if i enable the debug messages
If nothing helps, we need to debug audiod_get_AS_interface_index()...
Did you use the fix fix uac2_headset example #849?
Yes it's the latest master, and this PR is minimum.
Did you try disabling the debug messages?
Yes at first I didn't enable the log, since no data flow in EP IN I enabled it to see what happens.
we need to debug audiod_get_AS_interface_index()...
That makes sens, it should returns 1 ?
You have different return in your board ?
I never tested this example on my own. I only adapted the changes required for the new version of the UAC2 driver.
Looking at the example in more detail i see that there are two AS interfaces defined in the audio descriptors, yet CFG_TUD_AUDIO_FUNC_1_N_AS_INT = 1 is defined within tusb_config.h. It should be CFG_TUD_AUDIO_FUNC_1_N_AS_INT = 2 yielding alt_setting_1 to be of length two. If interface 1 is opened, idxItf = 0 should be th...
Thank @PanRe for reviewing the PR, I also did a quick check, the diff is a bit out of place, but actual change is very minimal. Should be no problem to merge.
I think it's a logic problem on tmp increment, tmp should increase only on alt0 interface descriptor, now it's good :)
uint8_t tmp = 0;
while (p_desc < p_desc_end)
{
// We assume the number of alternate settings is increasing thus we return the index of alternate setting zero!
if (tu_desc_type(p_desc) == TUSB_DESC_INTERFACE && ((tusb_desc_interface_t const * )p_desc)->bAlternateSetting == 0)
{
if (((tusb_desc_interface_t const * )p_desc)->...
Bingo, that should it be! Thanks for fixing this bug... my working example while developing that stuff did not cover this situation! I hope there are not many other possibilities i did not cover :D
Is the example working now?
Is the example working now?
Yes it works now.
I'll also add feature_unit_set_request for UAC2_ENTITY_CLOCK, change frequency is quite common.
Mh within dcd_edpt_xfer_fifo() you could buffer two frames before scheduling them. The first two ISO IN requests from the host may be answered by zero length packets according to the UAC2 specs i.e. when there is nothing to send.
Jep feel free to enhance it! Change of sample resolution from 16/24/32 bit may also be nice but is not mandatory. Some time ago i tried to do this, but i did not manage it to get 24 bits working on Windows. The standard UAC2 Windows driver ignored my 24 bit alternate interface setting for some reason i don't know yet. Have you done this before?
I haven't tried 24bit yet.
For EP wMaxPacketSize it can be figured out more smartly with maximum sample frequency, for example with xmos:
/* Max packet sizes:
* Samples per channel. e.g (192000+7999)/8000 = 24
* Must allow 1 sample extra per chan (24 + 1) = 25
* Multiply by number of channels and bytes 25 * 2 * 4 = 200 bytes
* TODO Output doesn't get modified by channel count
*/
#define MAX_PACKET_SIZE_MULT_OUT_HS ((((MAX_FREQ+7999)/8000)+1) * NUM_USB_CHAN_OUT)
#defin...
Mh i tried something like that... i read that the standard windows driver selects the alternate interface whose wMaxPacketSize is just big enough to handle the desired bandwidth. So i had
(48000 / 1000 + 1) * N_Ch * N_BYTES_PER_SAMPLE for N_BYTES_PER_SAMPLE = 2, 3, 4
But this did not work so far...
Anyway, thanks for fixing the example!!
The compilation error with GCC should be solved. I did not realize that the GCC throws an error on this. So there were only two solutions. Use a toolchain dependent compilation (like I did it now) or try to temporary disable the error while compiling (don't know how with GCC... only know it on CCRX).
Describe the PR
- Fix audiod_get_AS_interface_index in audio class.
- Enhance uac2_headset example with multiple sample rates.
- Add macro to calculate EP size.
Maybe it's because bInterval, in this example bInterval was 4 which should be 1, only the feedback EP should set bInterval to 4.
With bInterval set to 1 I can set wMaxPacketSize like in theory.
I pushed my changes in #938
Thanks a lot! A working example is always nice to have! Which program did you use to get the descriptors and the nice parsing of them?
According to the UAC2 specs, it is mandatory to define some synchronization type. Why did you remove it here?
Oops... But in UAC ISOCHRONOUS only is also valid
Which program did you use to get the descriptors and the nice parsing of them?
This one : https://www.uwe-sieber.de/usbtreeview_e.html
Ah ok. Well, i consulted the UAC2 spec again to be sure and there it is stated that you have to select one of the three types.
Operating System
Windows 10
Board
STM32L0
Firmware
Reproduce code:
tu_fifo_t ft;
uint8_t dummy[512];
uint8_t dummy2[512];
uint16_t n;
void main(void)
{
tu_fifo_config(&ft, dummy, 512, 1, 1);
ft.wr_idx = 466;
ft.rd_idx = 827;
printf("Count %d, rd_idx %d \r\n", tu_fifo_count(&ft), ft.rd_idx);
n = tu_fifo_read_n(&ft, dummy2, 200);
printf("Read %d, count %d rd_idx %d \r\n", n, tu_fifo_count(&ft), ft.rd_idx);
n = tu_fifo_read_n(&ft, d...
@PanRe Could you take a look when you have time ?
It's ok ,just need to force cast to uint16_t before comparison.
if ((p < (uint16_t)(p - offset)) || ((uint16_t)(p - offset) > f->max_pointer_idx))
Describe the PR
Fix fifo overflow correction.
Additional context
If applicable, add any other context about the PR and/or screenshots here.
Describe the PR
Add rx_rtt_printf() to work RTT logging with NEWLIB on Renesas RX family.
rx_rtt_printf() should be set to CFG_TUSB_DEBUG_PRINTF. The function just call SEGGER_RTT_vprintf.
Additional context
OPTLIB is removed from GCC 8.3.0.202002-GNURX. So, we need to make RTT work properly with NEWLIB.
I don't know why, but RTT didn't work via _write with NEWLIB. Using `SEGGER_RTT...
Ah thank you! The code was orginially designed for uint32_t (with all the overflows in mind). Could you do me a favor, could you include this case in the tu_fifo CI tests?
For advance_pointer
if ((p > p + offset) || (p + offset > f->max_pointer_idx))
{
p = (p + offset) + f->non_used_index_space;
}
else
{
p += offset;
}
I feel like the check can simplified into if (p + offset > f->max_pointer_idx)), have I missed something ?
Mh i thought a bit of the problem you described but i don't really see where the problem comes from and why casting to uint16_t solves the problem. After the first read, the second condition should hit as
(p + offset > f->max_pointer_idx) which is 827 + 200 = 1027 > 1023
and the read index should become
rd_idx = mod(827 + 200 + 64512, 16) = 3,
where 64512 is non_used_index_space . Do you have any ideas on this?
Would it be feasible to port cdc's guarding to vendor class driver?
IMO It would be better to have vendor class driver working until there is some unified streamed EPs API.
For
advance_pointerif ((p > p + offset) || (p + offset > f->max_pointer_idx)) { p = (p + offset) + f->non_used_index_space; } else { p += offset; }I feel like the check can be simplified into
if (p + offset > f->max_pointer_idx)), have I missed something ?
The first condition covers the case when p overflows solely by offset. It is possible that the second condition never hits i.e. if offset is big e...
After the first read, the second condition should hit as
It failed at 1st read, since the fifo is in overflowed state, in _tu_fifo_peek it tries to correct the rd_idx by backward the pointer.
I'm not sure which C language rule apply, but without casting to uint it generate signed compare machine code, since (p - offset) is negative the result is always false.
The GCC seem to be right about this. I got the warning when compiling with gnu++17, haven't got time to trace it down. So I put the warning comment here. Thanks for the PR.
The GCC++17 have the warning when compiling with this as well, since haven't got time to trace it down, I just put the warning comment there :D. For C : I think any expression involved minus will be treated as signed number ( I guess ).
// TODO warning: assuming signed overflow does not occur when assuming that (X + c) < X is always false [-Wstrict-overflow]
Superb! Thank you @HiFiPhile for fixing the issue and @PanRe for reviewing it. I will try to recompile with gcc++17 later on, and remove warning comment if it is indeed the case.
yeah, it is better to fix existing problem with vendor right now. If you could submit PR, I am happy to review. Otherwise, give me a bit of time, I will do it when I have time.
Once this is in motion, I can also help test with various similar-style controllers - also on Pi Pico (hopefully after mouse code is merged into base).
After the first read, the second condition should hit as
It failed at 1st read, since the fifo is in overflowed state, in
_tu_fifo_peekit tries to correct the rd_idx by backward the pointer.I'm not sure which C language rule apply, but without casting to uint it generate signed compare machine code, since
(p - offset)is negative the result is always false.
I see, thanks for fixing!
Thanks @HiFiPhile @PanRe for yet another P & review for audio. I am pretty much clueless for UAC2 at the moment. I push some example skip for mcu that does not have enough sram to run the example. Will merge when ci is passed.
Will merge when ci is passed.
Wait a little, I'll add handling when alt settings changes :)
Will merge when ci is passed.
Wait a little, I'll add handling when alt settings changes :)
no problem, please pull first to prevent any conflict, let me know when you are done.
since optlib is deprecated now, can we just remove it altogether and use NEWLIB since it is pretty standard on other ports.It is fine if you think we could still keep OPTLIB as an option.
That's indeed a good idea. I've tried to run the stack in PendSV in low priority triggered by SysTick with additional mutex, in this way I don't need a RTOS and I can have Delay() in main loop.
How fast did you call tud_task() from ISR? Every 125us to match USB2.0 microframes?
I need something similar and I was just wondering if I can call tud_task() from an ISR.
How fast did you call tud_task() from ISR? Every 125us to match USB2.0 microframes?
It's a STM32L0 @ 64MHz, since it's full speed so I call it at 3kHz without problem.
I haven't tried for high speed.
since it's full speed so I call it at 3kHz without problem
That's more than needed; you might be good at 1kHz as USB1.1 polls each 1ms.
What about the extra mutex? Is it needed? What do you lock?
That's more than needed; you might be good at 1kHz as USB1.1 polls each 1ms.
It helps on pushing bulk data rate.
What about the extra mutex? Is it needed? What do you lock?
In my case data read/write is also in the ISR, so I didn't use mutex.
currently it can only be safe to call tud_task() if you don't use RTOS. Otherwise calling the mutex API within ISR can cause issues depending on your RTOS. The idea of introducing tud_task_isr() is to skip mutex API.
currently it can only be safe to call tud_task() if you don't use RTOS. Otherwise calling the mutex API within ISR can cause issues depending on your RTOS. The idea of introducing tud_task_isr() is to skip mutex API.
Well, RPi Pico doesn't have an RTOS but I've spotted both mutex (irqs on) and critical_section (irqs off) used in code; don't know HOW they are used tough.
In any case yes, having a isr safe tud_task() would help a lot.
@PanRe I've added a fifo clear on set interface.
does not have enough sram to run the example
I've reduced the ram needed, maybe they can run now.
You're right, I'll remove it. I was thinking it was a pain to test with older version gcc. :smile:
Look great, thanks for the PR. Regarding the _write() hook, maybe renesas use an slightly differrent name for write such ash: write() or sys_write() msp430 has something like that as well https://github.com/hathach/tinyusb/blob/master/hw/bsp/board.c#L28 . Let me know if you want to check it out, this is already good for merge.
[hathach/tinyusb] New branch created: hid\-set\-report
Describe the PR
- better support for hid device set/get protocol
- add caplock detection for hid_composite (with/without freeRTOS) example.
[hathach/tinyusb] New review comment on pull request #913: Add dfu function memory access protection
since this function return void, you need to add extra , to return void, by default TU_VERIFY return bool value. Please change it to
TU_VERIFY( request->wLength <= CFG_TUD_DFU_TRANSFER_BUFFER_SIZE, );
Look good, sorry for late response, the issue with CI build is due to TU_VERIFY return bool by default. Could you fix this by adding extra , as review example.
Let me know if you want to check it out, this is already good for merge.
OK, I'll try the same way as msp430 and report back with the results.
@hathach
Thank for your advice. I confirmed that RTT works fine with the same way as msp430 on RX65N target board.
Following modifications were added.
- Extend stack areas, because there was not enough to work newlib's
printf. - Added some dummy functions, because some linker warnings occur when logging is enabled.
superb !! thank you, I guess it depends on the gcc version, seem like version 8 and before use write() instead of _write(). Glad that work out. I resolve the conflict and push update, will merge when ci passed.
@hathach I think it's ready to be merged.
Where does the divison by 256 come from?
Thanks a lot for rectifying the example and fixing the bugs in the audio driver and the fifo! This is a very nice piece of work you did here! Thanks a lot for the time! :)
@PanRe I've some problem in sending feedback. I want to call tud_audio_n_fb_set inside tud_audio_set_itf_cb to initialize feedback value to default value, but since _audiod_fct[func_id].ep_fbwas still 0, fb_val was sent in EP0.
Actually there are multiples tud_audio_set_itf_cb inside audiod_set_interface, in the callback there is no way to identify them.
@PanRe I've some problem in sending feedback. I want to call
tud_audio_n_fb_setinsidetud_audio_set_itf_cbto initialize feedback value to default value, but since_audiod_fct[func_id].ep_fbwas still 0,fb_valwas sent in EP0.Actually there are multiples
tud_audio_set_itf_cbinsideaudiod_set_interface, in the callback there is no way to identify them.
I see, this means we can not rely on the host to open the feedback EP first. Anyway, it should be possible t...
it should be possible to determine where the call comes from by parsing the request the call back function gives you
Actually there is no difference between ep_out and ep_fb, all fields are the same.
One possible fix is 12747b6
it should be possible to determine where the call comes from by parsing the request the call back function gives you
Actually there is no difference between ep_out and ep_fb, all fields are the same.
One possible fix is 12747b6
Not sure if i can follow you... Shouldn't the direction of the FB EP be of type IN and the direction of the OUT EP of type OUT as checked in line 1642 wit...
checked in line 1642 within audio_device.c
What was checked is the endpoint descriptor, with the EP descriptor it's easy to identify them.
But what passed to the callback is tusb_control_request_t, I printed all fields, for ep_out and ep_fb they are the same.
Ahhh man, i need more sleep ^^ Yes you are right! Mhhh... ok it seems passing the request pointer to the user is kind of useless then. How about splitting the CB into four parts: CB_EP_IN, CB_EP_OUT, CB_FB_IN, and CB_FB_OUT. I am currently not sure which parameters to pass for the CB functions but i guess those which are parsed within set_interface() are enough for the beginning! What do you think?
What do you think?
I think we can simply pass both ep_desc (or ep_addr) and p_request, actually p_request is useful since interface and alt number are inside.
Describe the PR
Add SUSPEND/RESUME handling for Renesas RX family.
Additional context
I have confirmed suspend/resume works with hid_composite example on rx65n_target.
But, DCD_EVENT_UNPLUGGED is not issued like before. I have no idea why VBINT(it is the VBUS changing interruption) is not occurred when the USB cable is removed.
does anyone know of a good tutorial for tinyusb on the raspberry pico in c?
OT: looking onto claim/release functions, they are using mutex with RTOS... Did you consider using atomic_compare_exchange? It may require chaging that struct to bitfield (I am not very familiar with atomics in C, I work in C++), but locking mutex seems like an overkill for this.
I guess the method is still under consideration. #662 mentions atomic operations for ARM architecture.
FYI, RTX implements atmic_wr8 by using these instructions.
I'm trying to communicate between two Picos using CDC, the exchange goes:
- A->B init
- B->A data (repeated every 100ms)
- A->B ack (at least every 2000ms)
I'd gotten as far as receiving data, but when I try to send the ack, it hits a panic: ```*** PANIC ***
ep 2 out was already available```
Is this a stack bug or am I doing something wrong, eg are there restrictions on where/when I can call tuh_cdc_send?
I've tried in either a cdc_task function in the main loop, or via a timer callback, same result in both cases.
found a comment here which I think may explain: https://github.com/hathach/tinyusb/discussions/925#discussioncomment-933932 - the RP2040 USB controller can only do a single bulk or control transfer at once, which isn't what the host code expects... wondering if that's my issue
OT: looking onto claim/release functions, they are using mutex with RTOS... Did you consider using atomic_compare_exchange? It may require chaging that struct to bitfield (I am not very familiar with atomics in C, I work in C++), but locking mutex seems like an overkill for this.
There are 2 issue
- atomic is gcc extension, also it kind of requires C11 or higher, not sure but it is technically resolvable (just take time...
@HiFiPhile seem like some of mcus still failed to run, would you mind adding back those skip files to get ci passed. @PanRe I will reply on you to review this PR. Please let me know if you think all your questions for this PR is resolved then re-approve it again.
hmm, this is a bit odd, SOF should be recognized by hardware as Resume signal. Do we really need to do it manual ?
I am agree your guessing. But unfortunately, RX does not signal resume interrupt caused by dcd_remote_wakeup() , in my experience. Of course, when the host resumes on its own, it occurs resume interrupt.
would you mind adding back those skip files to get ci passed
Now it's better.
Thanks for putting in the effort to get this example at least partially working on the esp32-s2. I have been able to confirm that it at least brings up a valid network interface on Linux. For some reason Windows doesn't want to pull an IP address, but I've had that issue in the past, so It's not surprising. As you say, the web server is not working.
Any thoughts on moving this forward? The S2 seems like an obvious target, since it already has a full network stack.
@kkitayam I see, that is a bit odd for rx65n controller for not raising Resume interrupt in this case. Could you put an comment explaining why we need to manually send resume event here. Just in case when going back to this and/or we could figure out a better way to detect resume.
I think we don't really need to blocking wait here,which could take a few ms, just return. We will send resume event later on with SOF walkaround. The usbd has its own suspended status bit, and shouldn't do any transfer until RESUME event is reported by dcd.
[hathach/tinyusb] New review comment on pull request #913: Add dfu function memory access protection
I think this is not really needed, since the transfer is limited by wLength which we already TU_VERIFY as above. The usbd_control will truncate any data exceeding the wLength
Thank you @xmos-jmccarthy for your PR to address the security issue, I guess you are busy with other works. And the comment is easy to fix, therefore I made the modification myself to help with the pr. Will merge when the CI is passed.
Sorry, I am still lacking behind in term of PR, will try this and integrate this as part of stock examples when I have time to test it. Please be patient
I have a second thought though, I think ZLP should only be sent when there is no data and the last packet is multiple of endpoint size) much like cdc https://github.com/hathach/tinyusb/blob/master/src/class/cdc/cdc_device.c#L469 .
Comments are added at 1ff3b76.
The statement is removed at 1ff3b76.
Describe the PR
- Add alt settings support in DFU class, in order to flash multiples partitions (FLASH1, FLASH2, EEPROM, etc.)
- Fix inverted ATTR_MANIFESTATION_TOLERANT logic.
@xmos-jmccarthy could you take a look if it ok ?
Maybe additional buffer check is needed if transfer size is different for each alt settings.
Shouldn't that be CFG_TUD_AUDIO_ENABLE_DECODING since it belongs to an OUT EP?
Maybe it's better to add TUD_AUDIO_PREFER_RING_BUFFER after #926 ... Or even take this change into #926
Mh i don't see your commit with the ring buffer on/off switch in the review section. Is this intended or is something out of sync here?
Mh i don't see your commit with the ring buffer on/off switch in the review section. Is this intended or is something out of sync here?
Since xfer_fifo of dcd_transdimension hasn't been merged yet and I added macro for lpc, I hesitate a little and put it in #926
Okay! Do you intend to add some more on this commit or is it finished?
I think I'm finished.
I have a question about interleaved copy decode/encode, nBytesToCopy is nChannelsPerFifo*nBytesPerChannel, in case of 2ch/24bit & 2ch/32bit nChannelsPerFifo has to be 1 since it handle only 1-4 bytes copy ?
I think I'm finished.
I have a question about interleaved copy decode/encode, nBytesToCopy is nChannelsPerFifo*nBytesPerChannel, in case of 2ch/24bit & 2ch/32bit nChannelsPerFifo has to be 1 since it handle only 1-4 bytes copy ?
Actually no, you have found another bug here! Instead of nBytesToCopy it should be nBytesPerSample i.e. audio->n_bytes_per_sampe_tx within audiod_interleaved_copy_bytes_fast_encode and likewise for the decode function. The amount of bytes t...
I think I'm finished.
I have a question about interleaved copy decode/encode, nBytesToCopy is nChannelsPerFifo*nBytesPerChannel, in case of 2ch/24bit & 2ch/32bit nChannelsPerFifo has to be 1 since it handle only 1-4 bytes copy ?Actually no, you have found another bug here! Instead of
nBytesToCopyit should benBytesPerSamplei.e.audio->n_bytes_per_sampe_txwithinaudiod_interleaved_copy_bytes_fast_encodeand likewise for the decode function. The amount of byt...
Could you incorporate that bug fix here please?
Like this ?
On LPC performance is quite awesome. Total CPU usage is only about 12% while streaming 32bit/384k ;)

Could you incorporate that bug fix here please?
Like this ?
Jep, thanks!
A very big thanks to @HiFiPhile for all the effort and time he spent on improving the audio driver! @hathach, i am happy with all commits, PR is ready for merge!
Good catch on the manifest bit logic.
For the alt setting, can you add an explicit initialized value in void dfu_moded_init(void) and the reset value in dfu_moded_reset.
Maybe additional buffer check is needed if transfer size is different for each alt settings.
CFG_TUD_DFU_TRANSFER_BUFFER_SIZE will have to be set to the largest buffer size used by an any given storage type. The recently added checks to prevent out of bounds memory accesses should be sufficient to catch these cases and alert the user if they make a mistake, but if you could add a note of that to the API header that would be great.
Superb !! Huge thanks to both @HiFiPhile for the awesome PR and @PanRe for reviewing. I wished I could help better with audio driver, however, my experience and knowledge with UAC 2.0 is very limited at the moment.
For the alt setting, can you add an explicit initialized value in void dfu_moded_init(void) and the reset value in dfu_moded_reset.
you could add a note of that to the API header that would be great.
It's done in cf4220a
comment need to be updated to include ALT
Thank for the PR, using alt interface as partition doesn't seem to be standard for USB DFU but it is popular with dfu-util. Adding Alt to callback is a good option. Though we need to keep an array of attributes and make sure it is multiple ALTs and not multiple instances of DFUs.
the logic is not correct, drv_len keep increasing, while we keep decreasing it which make it more like a division
should be while(drv_len < max_len)
using alt interface as partition doesn't seem to be standard for USB DFU
In fact it's in the spec:
* Alternate settings can be used by an application to access additional memory segments. In this case,
it is suggested that each alternate setting employ a string descriptor to indicate the target memory
segment; e.g., โEEPROMโ. Details concerning other possible uses of alternate settings are beyond the
scope of this document. However, their use is intentionally not restric...
@Wini-Buh unfortunately bitfield is used widely throughout the stack, it is probably too much of hassle for now to change it. I think we should still get bit endian correctly with pragma.
In fact it's in the spec:
* Alternate settings can be used by an application to access additional memory segments. In this case, it is suggested that each alternate setting employ a string descriptor to indicate the target memory segment; e.g., โEEPROMโ. Details concerning other possible uses of alternate settings are beyond the scope of this document. However, their use is intentionally not restricted because the authors anticipate that implementers will d...
@Wini-Buhhow I am still catching up with this PR. Would you compile rxcc on windows with stock example, I tried to use make command, however, since rxcc use different compile and linker option from command line than rxgcc and I don't understand it enough to make change to makefile to get it compiled. I guess you are having an e2studio project file, It would be great if you could share the file so that I could compiler and test it out.
dfu-util doesn't take care wTransferSize of Alt settings, I've opened a ticket about this.
In fact I missed out that only one functional descriptor is used in DFU class. (Thanks to dfu-util maintainer)
I think in this case we need a refactor which expose only one time parameters in functional descriptor. Some VA_ARGS trick like TUD_BTH_DESCRIPTOR ?
@hathach I will try to build a "stock example" with the e2studio and give you the project file. But I need to do that at the weekend and I can't test the example because I do not own the board used for the RX examples. In the meantime I show you the arguments given to the compiler, assembler and linker so you could see the how the command line options look like. You should find the description of each argument in the manual of the toolchain.
[commandline_options_examples.txt](https://github....
@hathach Ok, if will try to investigate more on this topic. I'm not sure if it is a problem of the toolchain (my hope was to reproduce the issue with the GCC, but because it is not possible to get the same settings with the bit field ordering the try was hopeless).
In fact I missed out that only one functional descriptor is used in DFU class. (Thanks to
dfu-utilmaintainer)
Indeed, I totally missed this one as well, I just checked the specs, it will be only 1 Functional DFU descriptor at the end after the series of the Alt Interface
ALT 0
ATL 1
ATL n
DFU Functional
I think in this case we need a refactor which expose only one time parameters in functional descriptor. Some VA_ARGS trick like
TUD_BTH_DESCRIPTOR?
we prob...
Describe the PR
Add audio format settings for Renesas RX family.
Additional context
The maximum packet size limit in the standard is 1024 bytes as ISO EP, but the RX USB controller only supports up to 256 bytes. The current configuration of the master branch requires a minimum of 384 bytes and will not work with RX.
Operating System
Windows 10
Board
custom LPC1788
Firmware
custom firmware
What happened ?
TinyUSB with msc example got configured with 48 msc_disk[] blocks, 512 bytes each. Adding up to 24kB in total.
Writing a 16k file will start on SRAM memory blocks msc_disk[6] to msc_disk[21], then proceeds writing on block msc_disk[3] to msc_disk[5].
First: written blocks are less than 16kB (reading back file shows missing bytes as undefined, see screenshot)
Second: would ...
hmm, I have a feeling this may not be TinyUSB bug at all. It probably has something to do with FAT FS. The msc ramdisk example is a quick hack. You probably need to have a better fatfs implementation. TinyUSB work well with elm-chan fatfs on actual flash device and ghostfast (virtual fs) https://github.com/adafruit/tinyuf2/blob/master/src/ghostfat.c.
However, lpc1788 isn't used much, It could be lpc1788 specific issue. Can you try to enable the LOG=3 to see if there is any abnormal in t...
Same with me. I suspect it in the msc example source as well. Today I will step throu the code and set some breakpoints in order to see how block number sequence is generated and why not all of them are written.
thanks, a project file to compile with stock example is very useful, if you could make one for cdc_msc (for testing) then the net_lwip_server as well so that I could help. The example for compile option txt is useful, I wish I know these well enough to put that into makefile to easily switch between rxgcc and rxcc. But I don't think I could pull it off, and could be error prone. It is better to address one thing at a time and stick with things that work first.
Do you happen to have any samd21/51 or nrf52, pico boards to test with. Those are most used and tested mcus, just to rule out lpc1788 specific issue. Note: If you need my help to test this, please attach
- modified example of cdc_msc
- your 16KB file that is used to write to the disk
Note: I forgot to mention, the ramdisk example have 1 cluser = 1 sector = 512 bytes, you need to keep it in mind when inteprete the fat data, and need to make sure the total data (file payload + overhead) is...
Thanks for picking this up. There is not enough ram to further increase ramdisk.
But after some debugging with 512byte sectors I can say:
- all sectors are written to 24kB ramdisk now
- unfortunately ramdisk is still starting 1st file at ramDisk sector 6
- missing sectors in flash are related to an LPC ram to flash copy problem (IAP copy function raises source address problem, probably because of some AHB peripheral blocking its access)
Because of point 3, I decided to complete...
Drive size is reported 0kb when using 4kB sectors with following FAT12 setting:

after reading your update, I am absolutely sure that this is purely application issue regarding the Fat filesystem which is not an USB bug. Since it is not within the scope of usb stack, I will move this to discussion, maybe there is other people with more FAT knowledge could help.
Describe the PR
This is a rough first draft to support the GD32VF103 RISC-V MCU by GigaDevice. It uses the same Synopsys USB OTG full-speed peripheral that is found on the STMF105 and STM32F107. I have added the nuclei-sdk that adds support for the GD32VF103. I chose to extract register definitions for the OTG peripheral from the stm32f105.h headers and put them into synopsys_common.h in order to not rename all registers in the sources, ...
how do i approach the cmsis @hathach ? should i merge into the microchip driver repository? right I'm relying on this https://github.com/cmsis-packs/cmsis-dfp-sam3u
I have several comment, but also tried push commit for some of them as well.
we could just use drv_len as total_len
why do we need to store the block and length instead of invoking callback ?
I think we could just skip this check, we will just use the last ITF found for DFU.
I would much more prefer to not store these at all, what is the issue with the existing code ?
also change this from set_timeout_cb() to generic get_status_cb()
I push more update to rename get_status_cb(). The PR looks good now, though I still have question regarding your introducing of block and length to the state.
_dfu_state_ctx.block = request->wValue;
_dfu_state_ctx.length = request->wLength;
I forgot to delete block and length. With one functional descriptor they are not needed.
I still don't quite understand, why wouldn't we just call the dfu_req_dnload_reply() here as existing code does.
In order to make the timeout set in tud_dfu_get_status_cb work it has to be called before the blocking period of flashing. So I have to delay the flashing callback one step later in the state machine.
I'm trying to compile USB midi test for the feather esp32s2, and after fishing for the includes,
I get the error in "tusb_config.h" that CFG_TUSB_MCU must be defined.
Inside "tusb_config.h" it says it's defined it "board.mk", but such file doesn't exist for any of the esp32s2 boards, only a "board.cmake" and "board.h".
Am I missing something here? Or is the board.mk really not present for the esp32s2?
[hathach/tinyusb] New branch created: fix\-midi\-data
Describe the PR
Fix off-by-one return valued of midi stream write, which causes https://github.com/adafruit/circuitpython/issues/4895
please revert the change, the req download reply callback should be invoked by its own request.
It is not correct approach, please revert the change. with the download callback, whenever flashing is complete application should call tud_dfu_dnload_complete(). tinyusb will response as busy in the mean time.
It is not correct approach, please revert the change. with the download callback, whenever flashing is complete application should call tud_dfu_dnload_complete(). tinyusb will response as busy in the mean time.
No it is the correct approach !
tinyusb will response as busy in the mean time.
As the CPU is blocked by the Flashing process (Flash is even stalled) how does tinyusb respond ?
Take a look at DFU diagram, device should start flashing after the DFU_GETSTATUS response.

And my discussion with dfu-util maintainer also confirm this:
The device should allow the data tran...
@HiFiPhile oh, I see, device need to response to get status first before performing the flashing. In that case, It make sense
@HiFiPhile oh, I see, device need to response to get status first before performing the flashing. In that case, It make sense
Yes, it's exactly the case.
@HiFiPhile oh, I see, device need to response to get status first before performing the flashing. In that case, It make sense
Yes, it's exactly the case.
I am doing more rename and update to DFU, will push when complete.
@HiFiPhile it need a bit more work, the get_status should allow application to report error such as incorrect address (such error can be from incorrect download file from host). I will do a bit more update for that

it need a bit more work, the get_status should allow application to report error such as incorrect address (such error can be from incorrect download file from host).
Ok, errAddress could be useful.
@HiFiPhile @xmos-jmccarthy I have updated with lots of rename (minor) and also tweak behavior as well as flow for DFU callback . I also migrated away from state machine since I found it a bit more complicated (left in code for review only). In sum up
get_timeout()will be invoked (by GET_STATUS) before download_cb() and manifest_cb(). Since either has potential flashing op.finish_flashing(status)( renamed from download_complete() ) is called from application after download/manifes...
I think it's in good form with a quick look, will do some real world tests.
I like the callback changes, this is much nicer to look at.
I will update my port and run some tests on hardware. I should be able to do that next week at the latest.
I will also integrate this to tinyuf2 project as well to see if there is any issue with existing API https://github.com/adafruit/tinyuf2
I've done some tests on LPC4337, so far so good.
I ported the initial driver from the samx7x, without dual port and dma implementation to reduce complexity, I have yet to test compile, but everything should be more or less ready.
If anyone could take a look to try to catch any major oversights by me, I don't know If I fully understood the working of the usb core :sweat_smile:.
I'm going to be out for a week, I won't pick this up again until then.
@hathach Here are the two e2studio project files of the cdc_msc stock example. I setup it up for a RX65N Cloud-Kit, which unfortunately I didn't own. That means I could not test it. I could only compile it with the CCRX. After all I'm not sure if it is very useful for you, but please have look at it.
project_files.zip
What is the current status with the documentation? It seems it has been left on hold while prioritizing other parts of the project, not criticizing ofc, I say this because of things like the domain www.tinyusb.org, is this the case?
That said I wanted to contribute and do some work on documentation, I think some online pages like this are best, is it ok If I work on that?
If so, what approach would be best? we can use something like github p...
Signed-off-by: Rafael Silva
Describe the PR
The project is young, but we already rely heavily on Tusb and we are planning on working on it in foreseeable future as well as develop a community around it, so i think it makes sense to add here.
As mentioned previously, #693 should be merged first, then we will generalize that driver to also support sam3u. Same driver should share a same dcd, that is hard at first but pay off later since it helps maintaining and fixing bug afterwards
thank you for your willing to contribute, indeed, documentation is lacking behind. since I don't quite have time to do it. For the approach, indeed, I prefer to to readthedocs #6 , the docs will be served via github pages. The domain is mostly for redirecting. Though, I haven't got time to set them up just yet, any PRs are welcome.
I've also (finally) tested ISO transfer. I think it's ready for test.
@HiFiPhile I only use auto format with portion of text selection where I want to. Normally I will just manual type it. Auto format is not enabled, since I couldn't figure out how to get it auto align =. Also it is a bit too strict, as long as the code look good, it is ok to go over line boundary (which I set to 120) or break rule. It is not too important, don't worry too much about it.
Great, in a week when I return from vacation I try to allocate some time for this
Thank you for your update. Everything looks great, I have an same70 explained, that could be used to test with. Though please revert the changes for exposing cdc fifo rx/tx, I think you probably got mixed up with your local branches.
[hathach/tinyusb] New review comment on pull request #693: SAMx7x \(E70, S70, V70, V71\) DCD Support
should be reverted since it has its own pr.
[hathach/tinyusb] New review comment on pull request #693: SAMx7x \(E70, S70, V70, V71\) DCD Support
possibly typo, this should be reverted
[hathach/tinyusb] New review comment on pull request #693: SAMx7x \(E70, S70, V70, V71\) DCD Support
should be reverted since it has its own pr.
Operating System
Windows 10
Board
STM32H7
Firmware
examples/device/dcd_msc (tinyUSB 10.1)
What happened ?
The dcd_synopsys.c driver fails to flush when the data to flush is exactly 256 bytes in length in HS mode. Writing more data will eventually cause a flush but calling to flush with 256 bytes of data does not actually perform the transfer.
The line that I believe causes the issue is:
https://github.com/hathach/tinyusb/blob/21bfd11683c4bb6e0996130bd1061a97d3049121...
Unsigned overflow/changing requirements strikes again :(. This is definitely wrong, and was probably there since the initial PR. When I originally wrote the driver, I wrote it for a board without a HS PHY. HS was completely out of scope, and I don't think tinyusb supported it at all. In FS, the max xfer is 64 (IIRC), so I used a uint8_t and forgot about it. When HS support was added, the maximum possible xfer size went from 64 (IIRC) to 512, and nobody (incl me) updated that var to account ...
@BennyEvans ah great, thanks, these are spot-on, as @cr1901 mentioned, this is originally written for FS. I did an update to support HS, but didn't update it properly. Would you like to submit an PR for the fix. If you don't have time, no problem, I could fix it myself.
I have tested this out on my same70 xplained board. It works well with board_test work for led & button. However on cdc_msc & hid_composite examples, but I couldn't get it enumerated at all.
here is my compile output (gcc9.3.1) , size seems to be a bit small
LINK _build/same70_xplained/cdc_msc.elf
CREATE _build/same70_xplained/cdc_msc.bin
CREATE _build/same70_xplained/cdc_msc.hex
text data bss dec hex filename
11080 8244 5060 24384 5f40...
Are you also doing test with same70_xplained or other board
I test on same70-xplained and my own hardware.
It seems in board_init it lacks the switch to external xtal, and UDP_Handler should be USBHS_Handler
I'll try to update the BSP with my clock config:
/* Marco for register access */
#ifndef CLEAR_REG
#define CLEAR_REG(REG) ((REG) = (0x0))
#endif
#ifndef WRITE_REG
#define WRITE_REG(REG, VAL) ((REG) = (VAL))
#endif
#ifndef READ_REG
#define REA...
@HiFiPhile thanks for the update, it is better, but still seems to be stuck after enumeration (descriptor is fine), msc disk does not show up, cdc connection doesn't quite work. I also found the usb bus does not work when I tried to hook it with hardware analyzer, which is weird !!
Fixes an issue (#968) in the dcd_synopsys.c driver where it fails to flush because of an integer overflow in HS mode.
Cheers, no problem. I've just created the PR.
superb ! thank you for your PR, you really got an eagle eye to spot this issue.
Operating System
Windows 10
Board
ESP32-S2 Dev
Firmware
TinyUSB library, Arduino IDE, ESP Core 2.00A,
What happened ?
Hello! Sorry to start new issue, but I waste a lot of time with compile any example. I try Adafruit, Chegewara libraries, but anyway I didn't get any succes. Can you help me with list of all required steps and addons do be able to flash my chip? Or link with tutorial, or advice which IDE to use? Due to fact of using Windows 10, I'm not able to do like de...
I think something is wrong with the redundant init of clock, I removed the clock init in dcd and there is no more enumeration failure.
Once again EP0 bugged, OUT packet miss-aligned by one transfer.
USBD Setup Received 21 20 00 00 02 00 07 00
CDC control request
Set Line Coding
Queue EP 00 with 7 bytes ...
USBD Xfer Complete on EP 00 with 0 bytes
NULL
CDC control complete
Queue EP 80 with 0 bytes ...
USBD Xfer Complete on EP 80 with 0 bytes
USBD Setup Received A1...
Clock initiation is supposed to be done outside tinyusb anyway is it not?
Clock initiation is supposed to be done outside tinyusb anyway is it not?
That also depends on the port, if the clock depends on bsp component such as xtal, and/or clock source etc. Generally, having it out of dcd make dcd more portable e.g easier to support other mcu such as sam3u etc..
@HiFiPhile I am currently busy on other work and couldn't help to fix this. We could merge this as it is and create an issue for it so that we could come back later on when having time. Of course, it...
Do Tiny USB have the corresponding demo for custom HID devices
You know what, I fight for NAKed transfer for 2 days with a bad cable !
This cable works on my lpc4357 so I assume it's ok but in fact the connector of same70-xplained is a little loose lol...
Yes we can merge at current state as the data transfer works, I put a workaround for EP0 issue caused by spurious OUT irq, we can come back later to investigate.
There is an example of generic IN/OUT : examples/device/hid_generic_inout
It's pretty easy to customize, you can take a look of predefined descriptors in /src/class/hid/hid_device.h and replace TUD_HID_REPORT_DESC_GENERIC_INOUT with your own descriptor.
//--------------------------------------------------------------------+
// HID Report Descriptor
//--------------------------------------------------------------------+
uint8_t const desc_hid_report[] =
{
TUD_HID_REPO...
Something like this? (Compiles, but not tested).
It does not exactly what you wrote in that it doesn't check for a multiple, but the equivalent of the endpoint size, because the actual transfer can't really be bigger than the EP size? Or were you referring to the last bufsize parameter to tud_vendor_n_write()? If so, I don't understand what you want to achieve.
Even so I don't fully get the rationale behind that requirement. On the protocol level, the device can still send p...
@zhangslice next time, if you want to ask an question, please post it in the discussion. Issue for code development
You know what, I fight for NAKed transfer for 2 days with a bad cable !
This cable works on my lpc4357 so I assume it's ok but in fact the connector of same70-xplained is a little loose lol...
It is probably more than the cable, I found that the bus is very sensitive. I could see it get passed enumeration if attached to the PC, but same70 refuse to communicate when using hardware analyzer. Which indicate it has some bus/phy issue.
Update: With [eec927e](https://github.com/ha...
I have pulled and tried the latest, unfortunately, it doesn't improve much, same result as previously with my ubuntu machine.
Could you force it in full speed mode to see if it helps ?
I force fullspeed by commenting out OPT_MODE_FULL_SPEED in descriptor but it doesn't help, it doesn't get passed enumeration at all.
Try change only BOARD_DEVICE_RHPORT_SPEED in tusb_conf.h, I use TUD_OPT_HIGH_SPEED in dcd init.
I've no problem running high speed with my AMD Arch pc, could you try my compiled cdc_dual_ports
same70.zip
@HiFiPhile with latest push the cdc_msc now work great yeah !!! For analyzer, you are right about the cable, it work with very short cable (0.3m length), while other 0.5-1m doesn't, even that it works with other HS board such as lpc18xx. I guess it is more peaky than others.
Finally it works, though I go further to test with net lwip example, but it failed that one. Look like setup is still missing, it is probably overrun or race condition.
. - rename CFG_TUD_EP_MAX to
CFG_TUD_ENDPOINT_MAX, default to DCD_ATTR_ENDPOINT_MAX (user can force smaller number for app specific to save sram).
It's simply because SAME70 need different EP for IN and OUT.
Now WebUSB echo works but I can't see \r\nTinyUSB WebUSB device example\r\n which is received in BusHound.
It's simply because SAME70 need different EP for IN and OUT.
Now WebUSB echo works but I can't see
\r\nTinyUSB WebUSB device example\r\nwhich is received in BusHound.
Ah thanks, I didn't notice that. Great, merge now, #975 will make it easier for cross-platform application to detect these requirement
Thank you @HiFiPhile for stating this PRs, and @xmos-jmccarthy for helping with the review. This PR is now ready, and I am glad that you are both happy with the changes. There is quite a bit of rename though, but it is to make it more like other class. If there is nothing else that need changes, I wink we could merge this. Any issues can be fixed as follow up PRs.
Everything looks good.
@perigoso #693 is finally merged, I've added several fixes later on mostly focused on EP0.
I can help review but since I don't have the board I can't test with.
@Wini-Buh late response, I tried to import your project files, though look like it expect some certains file structure, and also missing some of your local files to build. This is why I don't like from IDE, it takes lots time to configure and setting up for an port/board and may not portable to other users.

Anyway, since I got the gccrx working well now, I will try to update PR t...
@hathach I will try to build a "stock example" with the e2studio and give you the project file. But I need to do that at the weekend and I can't test the example because I do not own the board used for the RX examples. In the meantime I show you the arguments given to the compiler, assembler and linker so you could see the how the command line options look like. You should find the description of each argument in the manual of the toolchain.
[commandline_options_examples.txt](https://git...
@Wini-Buh late response, I tried to import your project files, though look like it expect some certains file structure, and also missing some of your local files to build. This is why I don't like from IDE, it takes lots time to configure and setting up for an port/board and may not portable to other users.
Anyway, since I got the gccrx working well now, I will try to update PR to my best effort so that we could merge this soon. Since the pr has been pending for so long, and have some...
Ok. Great to hear you got CCRX working well now. I mentioned that the project file alone maybe is not very useful for you.
If required I could of course build a complete e2studio project (with all sources) and send it to you.
Actually not rxcc, the gccrx though, sorry for not being clear enough. That allows to make changes, mostly rename compiler attribute and other minor clean up with confidence. I have push update to your fork to update PRs. Please pull first if you want to do furth...
It has been pending for awhile, although I couldn't get tested with ccrx, the modification look good. It also contains bug fix when using the stack with big-endian mcu (which isn't tested yet). I think it is best to merge it for now, and resolve the net_lwip_webserver example with ccrx as follow up PR later on. That example is complicated, there may need some config tweak with lwip (much like tinyusb) to work with rxcc as intended as well.
I did a bit of rename and cleanup (please do pu...
seems like a change in logic, I don't understand the mcu enough to decide if modification is correct. Maybe if you could, explain/confirm this a bit.
this is an 180 degree logic changes, though I think it is correct one. I understand that we are reading and waiting to confirm out num is written. But again, I am not entirely, though it is worth a confirmation.
I am still not convinced there is issue with bit-field within a struct. The bitfield order should give us the correct layout. Maybe it is endian issue. We could just enable the LOG=2 to see if the size of openning endpoit is correct or not. If you are busy, maybe we could revert this for now to get PR to merge first (I could do the revert).
sorry for late review, I have been late with other works. will try this out asap.
No Problem and thank you for helping with the debugging! ๐
I hope you and your families are safe and healthy.
[hathach/tinyusb] New branch created: readme
Describe the PR
2 README.md updates.
we should explicitly use its commercial name SAME7x. Although S7x, V7x are similar, but skip it for now until we actually have tested the hardware.
Is your feature request related to a problem? Please describe.
ST extension is aka DFU 1.1a has some special command such set address, erase etc... I am not sure if it is preferable over std DFU 1.1 but it seems to be popular.
I think this change is correct.
The codes are regarding load from misaligned address. At that time I thought that RX MCU has no support for load from misaligned address. But, it was my misunderstanding. In fact, it has support for load from misaligned address. So, the part is unnecessary.
We need also take care of DCDs who do automatic allocation, for example SAME70.
It allocate fifo sequentially, however if one EP fifo is freed/allocated, the data of next EP fifos are lost:

At the moment I don't free the fifo in dcd_edpt_close, so in next dcd_edpt_open call fifo can't become bigger.
It could be nice to allocate the maximum size at beginning.
thank you very much for confirmation :+1: :+1:
thanks, it is much clearer now. I think the PR is almost ready to merge :)
yeah, I will try to revise the endpoint API, I think we may move to dcd_edpt_iso_open() with dcd_edpt_iso_set_size() instead of closing and reopen. The driver could specifically open the iso with largest packet then set_size to 0 as disabled state and/or set_size() to other if needed.
@Wini-Buh is it OK if I revert this change for now to get this PR merged first. I am ok for this change in future PR, I only need confirmation that it does indeed needed for ccrx to work.
For me it's OK to revert it. It is definitively required in the project I'm using tinyUSB, which is build in big endian and left bitfield order. I have already setup test code to investigate the problem deeper (for me it looks like a problem of the CCRX toolchain if the configuration I mentioned is used... and if so, there is maybe another workaround for it).
I keep you informed about the result of the investigation about this problem.
@hathach I started some work on the docs;
here's a very early preview, lots to be done still:
https://perigoso.github.io/tusb_docs_showcase/
I tried to setup the readthedocs pages, but I don't have enough permissions on the repository, I would need admin rights. So you would need to set that up yourself, or give me admin rights temporarily but I understand that comes with trust issues.
You might notice the logo looks different, theres no particular reason for the change, except that I wanted an svg logo to embed in the docs and I had to make one from scratch, and I took some creative liberties.
Waveshare OpenH743I-C Board Support Package.
Describe the PR
Fix IAR warning.
Rework of the documentation
This unifies all the current information about the project in an online documentation page, this will be hosted on readthedocs.
This PR adds very little NEW information, but it builds a good foundation where further documentation can be built uppon.
To simplify the visualization of the PR the new docs can be preview here https://perigoso.github.io/tusb_docs_showcase/
Some docs need some priority work, like the new supported devices table, because i am not...
TODO:
we need to setup the readthedocs project, this can be done right after the merge by someone with admin rights.
we also need to setup the domain, an ANAME or ALIAS needs to be setup to point to the readthedocs page once its up.
superb !! Thank you very much for the hard work, it looks fabulously. There is only 2 minor issues
- I still want to keep most of the project information as part of the readme since that is where most github user will look at. I rather to present it right away than require an extra click to external doc page. We can rename it to readme.rst like contributors.rst
- The logo font doesn't look right, I would prefer to keep using the current logo. Do it need to be svg, I could try to export cu...
look good, thank you for the fix
You might notice the logo looks different, theres no particular reason for the change, except that I wanted an svg logo to embed in the docs and I had to make one from scratch, and I took some creative liberties.
Ah right, I notice that as well, to be honest, I like the old logo font more, I will try to export an svg using existing desgin file to use with doc page. Give me a bit of time, I am not really good with these image tool.
I managed to get tinyusb/CDC workin on a SAMS70, but had to adapt the code to
the new microchip include files from Harmony3 - XC32.
Detected a few cache/DMA issues that were solved with 2 clean/invalidate cache instructons.
Thank you very much.
I also eems to be getting error after flashing cdc_msc example on the fomu,
make BOARD=fomu CROSS_COMPILE=riscv64-unknown-elf-
dfu-util -D _build/fomu/cdc_msc.bin
See below:
[34541.026812] usb 2-3.3.2: USB disconnect, device number 50
[34541.298728] usb 2-3.3.2: new full-speed USB device number 51 using xhci_hcd
[34541.426773] usb 2-3.3.2: device descriptor read/64, error -32
[34541.662737] usb 2-3.3.2: device descriptor read/64, error -32
[34541.898728] usb 2-3.3.2: ...
Thanks for confirmation, I will leave it on for now since you actually need it for ccrx. We could update it later as follow up PR. However, the bmAttributes (just right above) also use bitfield within struct, you may also need to check it out as well. Too bad, I couldn't test ccrx myself, they make it difficult to run on Linux.
Anyway, when you have time please try to run an very simply example using tusb_desc_endpoint_t struct (copy it to helloworld example), then write an value to the wM...
Thank you very much for your PR. Let merge this as it is now, since it is good enough. For more issue with ccrx and net driver, we could resolve it later on as folllow up PR when having more time to work on it.
Hi @fjgpereira ,
had to adapt the code to the new microchip include files from Harmony3 - XC32.
So with Harmony3 the register defines are different ?
Detected a few cache/DMA issues that were solved with 2 clean/invalidate cache instructions.
In the DCD driver I haven't included cache clean/invalidate since it's configuration dependant. For example in my case I use DTCM/ITCM and set normal sram to non-cached.
I can add a define to enable them when needed.
@proppy this issue is more about stm32f4 as 1st post indicates, please open an new issue for the fomu.
since we don't need a strict timing, we could actually use nop or better use DWT from debug core to delay https://github.com/adafruit/Adafruit_nRF52_Arduino/blob/master/cores/nRF5/delay.h#L103 . Since I think this is primary reason for not integrating this board into the existing stm32h7 family folder.
oops, you are right on this, I will need to update bsp init (on other boards) to skip SysTick_Config when OS != None.
superb! thank you very much for your PR and effort to put the board hw issue note for user with same hardware. I understand there is a few special config for this board that prevent it to be part of the stm32h7 family here https://github.com/hathach/tinyusb/tree/master/hw/bsp/stm32h7/boards. e.g
- Different ULPI DIR, NXT pin selection than the reset (this is easy)
- Require an way to delay resetting PHY, but it is doable with nop and/or dwt I think
However, I still prefer to integrate it...
great info, I am sure it will be valuable to lots of other users.
maybe you could add an PR for cache, it is typically required on M7 mcu. I did something similar for rt10xx
https://github.com/hathach/tinyusb/blob/master/src/portable/nxp/transdimension/dcd_transdimension.c#L48
@hathach happy to help where I can and happy to test on my hardware if you integrate it later on. I agree that integrating it will be a better solution and less maintenance.
If you don't get around to integrating it within the next few weeks then I can have a go at it if you'd like? But I then run into the same problem of not having the other hardware to test on and ensure I haven't broken anything on those boards.
@hathach understood I thought it also applied here because of https://github.com/hathach/tinyusb/issues/179#issuecomment-615903720 and https://github.com/hathach/tinyusb/issues/179#issuecomment-616301515, will open a new issue.
Operating System
Linux
Board
fomu
Firmware
examples/device/cdc_msc
What happened ?
I seem to be getting enumeration errors after flashing cdc_msc example on the fomu:
[34541.026812] usb 2-3.3.2: USB disconnect, device number 50
[34541.298728] usb 2-3.3.2: new full-speed USB device number 51 using xhci_hcd
[34541.426773] usb 2-3.3.2: device descriptor read/64, error -32
[34541.662737] usb 2-3.3.2: device descriptor read/64, error -32
[34541.898728] usb 2-...
Hm, I understand, the problem with that is that you end up with 2 places with the same information that you need to make sure is updated at the same time.
Maybe we could link the internal files used in the docs in the readme, it should be readable on github since it's just rst, the user still has to click but doesn't need to go outside github, it's a good compromise?
I can do the logo myself, do you know the name of the font? If not I can trace manually. SVG is vector graphics so you can't e...
Hi,
The include files i found on the Harmony3 project seem to have suffered a few changes, but for the most part the symbols are the same.
For instance most macros now require a value/parameter, etc, the USBHS_DEVDMA array now is spelled in upercase, etc.
In case it has any use, I placed a patch/diff file with the changes at [http://inocam.com/~fjp/dcd_samx7x_H3.diff]
Regarding cache, everything looked to be working fine with ICache enabled and DCache disabled, but to enable DCache
...
@hathach I have rebased to the HEAD of the master branch. And, I have confirmed uac2_headset works fine with #956. I think that the PR is ready for merge.
@Wini-Buh If you don't mind, would you confirm whether this patch works or not on your environment?
Hm, I understand, the problem with that is that you end up with 2 places with the same information that you need to make sure is updated at the same time.
Maybe we could link the internal files used in the docs in the readme, it should be readable on github since it's just rst, the user still has to click but doesn't need to go outside github, it's a good compromise?
readme.rst should be displayed as readme.md on github if I am not mistaken e.g https://github.com/adafruit/circuitpytho...
maybe you could add an PR for cache, it is typically required on M7 mcu. I did something similar for rt10xx
https://github.com/hathach/tinyusb/blob/master/src/portable/nxp/transdimension/dcd_transdimension.c#L48
I think it's better to add a on/off switch, also for dcd_transdimension.
Clean/invalidate cache will cause hardfault in case of it is not enabled.
How I edited your comment :D
I think it's better to add a on/off switch, also for dcd_transdimension.
Clean/invalidate cache will cause hardfault in case of it is not enabled.
How I edited your comment :D
I didn't see any issue with rt10xx so far, I don't remember caching within stock example. If it is an issue on other MCU, it is better to detect if cached is enabled or not. Adding an macro is easy, but that config file is growing and already complicated to user (than I would like it to).
- It has been a while ( a year ) since last time I tested with fomu. I remembered last time I need to update its bitstream to certain version for it to work. Make sure you update it to latest first.
- Also, have you reported this issue to fomu team https://github.com/im-tomu , they understand their hw much better than me. If yes please provide the link, it may provide useful information to me. If not, please do so.
Thanks, I will try to put up an PR (if I could) and tag you for review.
here is the svg file,that I manage to create/export after quick google for how-to, please try to put that to the doc, I hope that is good enough tinyUSB_logo_svg.zip
I did a quick test... unfortunately it does not work. CCRX displayed some warnings, but at the moment I don't have the time to analyse it... (maybe next weekend). Enumeration seems to work (at least lsusb shows the device), but the device functionality (CDC in my case) does not work.
Don't know about Microchip plans, but I looked into the include files supplied with XC32 compiler and found that it also uses the new naming conventions.
I didn't check if there are any standard macros to detect the Microchip tools/versions, but as the registers pointer names are different, maybe you can use something like this:
#ifdef USBHS_REGS
#define USBHS USBHS_REGS
#define PMC PMC_REGS
define MP (1)
#else
defne MP
#endif
and then add __MP...
@hathach I think it's also possible to include register defines in tinyUSB, like dcd_transdimension.
It is possible, but (transdimention) tdi is a bit extreme since all naming and register address and mapping is totally different between lpc and rt10xx. It is probably needed if we also bundle sam3u etc into the same dcd. However, it will depend on actual register naming/mapping from microchip. The naming here is not that bad, it seems only take an extra argument for some macros. Anyway, I would prefer to review actual code before making any decision at all.
I did not investigate the reason why, but It was also necessary to add a __DSB() barrier
to dcd_event_setup_received() on usbd.c after a call to memcpy(), or else Setup events (GetStatus, etc.) were
not processed correctly.
How did you configure the MPU regions ?
Describe the PR
SAMx7x improvements.
- Add cache clean/invalidate.
- Move clock enable to BSP.
I'm making changes in #985 .
Actually most of the CPU initialization code and peripheral libraries is generated automatically by Harmony3 and I usually only look inside that code when I find some bug or hardware feature not implemented by the default code generated automatically, so I probably am not able to help.
However, MPU is disabled in the Harmony3 graphical tool, but I didn't check if it applies any default configuration.
Looking at the generated code, I also don't find any MPU initialization
(that is: I cann...
I also don't find any MPU initialization
That's strange... so basically Harmony3 enable cache without prior MPU region configuration ?
But by default the memory type of USB FIFO is 'Device Memory' so it's not cached...
I have rebased with the logo you provided, I also added local links in the readme to all of the documentation, it's not perfect, but it's good enough for a quick glance at the documention without leaving github.
notice:
I have brought down the documentation repo
You can merge if there's no changes you want made.
That's strange... so basically Harmony3 enable cache without prior MPU region configuration ?
I think that is the default Harmony3 settings for new projects.
When the MPU is enabled, it does offer a recommended configuration with 6 regions, ITCM, DTCM, SRAM, EBI_SMC, EBI_SRAM and QSPI, ranging from 0x0 to 0x8ffffffff, but I don't know what applies to 0xA0100000 without specifically defining another region.
And that is why Harmony is not used
Rebased on master, try not to merge anything that changes any of the docs before the merge
And that is why Harmony is not used
So far I've found a few bugs in the auto-generated code, specially with unusual device configurations, but all in all, I think it has saved me a lot of time. However, I almost only use CPU and peripheral initialization code, avoiding other libraries and RTOS.
The tools for pin assignment were specially useful to draw the board schematics, as it helped choose peripherals and assign pins to each function. I think it helped get the first prototype PCBs w...
And that is why Harmony is not used
I think it has saved me a lot of time
I think it's ture for every MCU companion software I've used (STM32Cube, MCUXpresso, Simplicity studio, etc.) while pin tool is practical for PCB planning, their generated code is very pathetic. I always ended with direct register access.
@Wini-Buh
Thanks so much for taking the time to test this patch. I guess there are something problems regarding D0FIFO handling. I will review this patch carefully again.
Sure you can save a lot of time, and if you're lucky you can have a good experience with it. But you run the risk of having a veeery bad time, it's just not reliable.
Sure you can save a lot of time, and if you're lucky you can have a good experience with it. But you run the risk of having a veeery bad time, it's just not reliable.
I suspected that and decided to use just a minimal set of features.
That's why I decided to try tinyusb instead of the Harmony's USB stack
that has lots of dependencies with other libraries and rtos.
For the same reason, avoided the E70 GMAC and corresponding TCP/IP stack and
instead chose an WizNet W6100 for TCP/IP.
@fjgpereira @perigoso
I've refactored register defines into a separate header, now it should be compatible with both frameworks and it makes porting easier.
I moved USB clock enable into BSP so you need to add
// Enable USB clock
PMC->PMC_PCER1 = 1 << (ID_USBHS - 32);
@Wini-Buh
I found the bug regarding D0FIFOSEL handling in pipe_xfer_in(). And I fixed it by 45e55a8. I hope this fix will make this patch work on your environment.
Alas, this seems to be a "feature" of the RNDIS driver bundled into recent Linux distributions. This newer Linux RNDIS driver fires off a bunch of RNDIS queries (via EP0) without first reading the notification EP response to the query/queries that it already sent. D'oh.
The workaround that Iโm tempted to submit as a PR would be to add an if-busy check to netd_report() in ./src/class/net/net_device.c:
void netd_report(uint8_t *buf, uint16_t len)
{
// skip if previous report no...
Success... Tested it in big and little endian configuration with CCRX on my test and on my product development environment and it worked so far. Thank you very much.
superb !! @kkitayam Thank you very much for your PR and @Wini-Buh for testing it out. Everything look great
[hathach/tinyusb] New branch created: fix\-midi\-available
Describe the PR
midi stream read() is often called with 1 byte buffer each. Correct the available() to also take in account of previous byte read from packet (not yet consumed). Reported by https://github.com/adafruit/Adafruit_TinyUSB_Arduino/issues/64
Wow, the code looks very nice! @j4cbo: Any updates on this one? Or is it worth that I work my way into this to be able to fix the outstanding review comments? I'd really be interested to have an easy solution to have one tinyUSB-network that works out-of-the-box on Linux, mac and win :+1:
@perigoso I added myself in CONTRIBUTORS.rst :) If you need make changes pls do a pull.
@j4cbo: Is the firmware you are talking about available somewhere? My CDC-NCM device enumerates perfectly fine but since I didn't yet get my code using tud_ncm_xmit to compile, no packets are exchanged.
Can you give some example on how to use tud_ncm_xmit (also using a LwIP-based stack here)? Thanks!
Okay, got it working. Commit still pending, need to clean up some bits. Just for quick reference:
New function:
void flatten(void *arg, uint8_t *buffer, uint16_t size) {
pbuf_copy_partial(arg, buffer, size, 0);
}
Then modify the existing linkoutput_fn:
static err_t linkoutput_fn(struct netif *netif, struct pbuf *p)
{
(void)netif;
if (!tud_ready())
return ERR_USE;
tud_ncm_xmit(p, p->tot_len, flatten);
return ERR_OK;
}
The existing example code duplicates functionality that it turns out can be achieved with an existing function in lwIP (pbuf_copy_partial). Using pbuf_copy_partial() saves about 24 bytes in the net_lwip_webserver executable size and results in ever so slightly less code to maintain.
@perigoso thank you very much for the update. This is a great update so far, I couldn't pull it off myself. However, in addition to dedicated documentation site, I still think the github readme.rst is one of the most important doc and should present the complete overview of the project like it does before. I wouldn't mind if there is duplication at this stage, we will try to enhance the rst doc later on (I still have to learn how to write doc for API anyway) and reduce the duplication later o...
Sorry for keeping you waiting, I have been overwhelmed with other paid work and non-work (real life) issue that we are all facing. Anyway, I finally manged to review this PR, it is much easier than I thought, you are doing a really great work !! Though there are only couple of minor feedbacks
- nuclei-sdk is overkill, please use the simpler firmware library from gigadevice for low level mcu. Since the stack doesn't need anything else
- please add the ST license to the
synopsys_common.h
nuclei-sdk is too overkill as submodule for just low level mcu driver. Furthermore, TinyUSB shouldn't reply on other project to provide hal layer. It is best to just use the mcu driver from the vendor, I think https://github.com/GigaDevice-Semiconductor/GD32VF103_Firmware_Library would be a much better sub-module, since we only need a basic one.
ah right, this is quite a pain that GD32V name register differently despite they are pretty much the same thing. I am ok adding this for gd32, some other non-stm may need this as well since synopsys dwc controller is quite popular. There is only one issue though, I think most of the definition is from ST driver, we should keep their license in this file, luckily it is compatible with MIT so we are all good.
No Problem and thank you for helping with the debugging!
I hope you and your families are safe and healthy.
Thank you, same to you. Sorry for late response again.
@j4cbo, to help your PR be more presentable, I've speculatively done a new branch based off the current TinyUSB code that uses a modification of your driver.
The most important change to the driver code is to address the issue that I originally raised in Nov 2020: compatibility with the existing network API. I had to make two minor tweaks to the existing API to accommodate your driver:
- tud_network...
That is fine, i understand. merged.
Perfect, I wasn't sure if you would be fine with this "hack". I have added the stm32 license header.
I completely agree that the nuclei-sdk is overkill for this port, but I had chosen it over the multiple other repositories of the GD32VF firmware on github because their repository is the most up to date one and actively maintained by nucleisys which provided the RV32 core IP. Furthermore there is a bug in the startup code that throws an compilation error if -Wundef and -Werror is used with GCC, for which I had opened a PR. Therefor...
I have rebased on the latest master and pushed my changes! Thanks for your review and no need to apologize, I hope everything is well :-).
If you find the time, then I'm curios what you find out about the strange errors I had with the demos and tinyuf2 bootloader.
Hi @majbthrd: Thanks for having worked on this! I've had a look at the code and used it in my project. It works just as fine as the version in this PR, with fewer changes in the library-using code. Well done, thanks!
Of course, it's still an API-breakage for everyone using tud_network_can_xmit I guess?
I've added the "Microsoft OS 2.0 compatible descriptor" with "WINNCM" string to my project. The device works like before on Linux. Didn't test macOS this time. On Windows, the device enum...
Hi @majbthrd: Thanks for having worked on this! I've had a look at the code and used it in my project. It works just as fine as the version in this PR, with fewer changes in the library-using code. Well done, thanks!
Thanks @kripton
My goal was keeping things as similar as possible, but if complete backwards compatibility is deemed necessary for code acceptance, this can be remedied by having a new API tud_network_can_xmit_bytes() to provide the size that the NCM driver wants and the...
@perigoso thanks for updating, though please revert the re-org change, since I like the original one more.
I pull the nuclei and did a quick check, the https://github.com/GigaDevice-Semiconductor/GD32VF103_Firmware_Library is more updated in term of the mcu driver. The last activities you said in 2020 is update the mcu lib to v1.1. while nuclei still uses the v1.0 version. nuclei is more maintained by it is mostly for their platform, tinyusb is only interested in low level mcu driver (clock, register def). Therefore I think it make more sense to move to the said repo.
I am not familiar with riscv and I am not sure if nuclei nmsis is as universal used as arm cmsis. If we didn't use it much e.g only enable/disable IRQ, maybe it is best to just use the low level code from giga firmware. That will allow user to run tinyusb with bare metal without the need for nuclei sdk.
I have rebased on the latest master and pushed my changes! Thanks for your review and no need to apologize, I hope everything is well
If you find the time, then I'm curios what you find out about the strange errors I had with the demos and tinyuf2 bootloader.
I will look at that, though I think firstly we need to make sure all stock examples in this repo run well with vf103 first. Since it is new port, it ma...
I'm a bit confused the latest firmware library from GigaDevice is 1.1.2 from June 2021 but can only be found on http://www.gd32mcu.com/en/download/0?kw=GD32VF1 so all the repos are outdated. Judging from the activity in repositories all but nuclei-sdk seem to be unmaintained, as no pull request are merged or answered.
I hope that I don't bother you with this discussion, but I think that nuclei-sdk is the better choice from a maintenance perspective and I would happily open a PR to update t...
The whole risc-v ecosystem is really young and because of the decentralized and open nature of the ISA I doubt that something universal as CMSIS is going to emerge. So NMSIS is largely Nuclei specific as the processor core have vendor specific extensions but very well designed in my opinion. It also provides a CMSIS compatibility layer. Although for this port very few parts are actually used.
Thank you and I totally agree with the sentiment. Maybe this PR would have been the better place to add errors I already encountered with the stock examples:
Thank you very much @perigoso, this is a huge thing in my todo list. And I surely wouldn't pull it off without your help. This PR will make future updating document much easier than ever. There is still no API docs yet, but we will slowly but surely fill it up later on.
[hathach/tinyusb] New branch created: perigoso\-readme\-patch
Is this technically done with #983 ?
Close after readthedocs is setup
yeah, I think this can technically be closed. There is always more docs to write much like codes. Thanks again.
@hathach github-pages branch is now redundant no?
@perigoso it currently is only used for hosting the webusb-serial server part. we could move it as part of the new docs site, it is pretty static.
I am not bothered at all, I have looked a bit more closer. To be honest, at first I thought Nuclei is a 3rd party, but look like they are IP creator similar to ARM. And Giga put Nuclei's N200 risc-v core into their silicon. Furthermore, Nuclei seems to spend much more effort on the software/firmware side than Giga does. And I could see why you prefer to go with their sdk. Feel free to correct me if I get it wrong.
https://github.com/Nuclei-Software/NMSIS is indeed a really great repo whic...
looking more at nmsis, I think it is a great repo. I will leave to you to decide whether we should use nmsis here. Note that, anything used in this dcd file will be considered as tinyusb dependency.
Waiting on #985 to redo this
I just notice this file in the bsp, is there any reason that you don't use the system_gd32vf103.c included by the firmware library instead since this file is mostly "fixed" per mcu.
Yeah, I honestly don't mind the API change. I could have also lived with the much-changed API proposed by this PR if I can just have NCM working on Linux, macOS and Windows hosts ;). But of course less changes are to be preferred and it makes totally sense to not just ask if an xmit is possible but if an xmit with X bytes can be done. So the API change makes sense in the end.
I can confirm that the code from @majbthrd's branch is working fine on Linux (5.13.4, amd64), macOS (11.2.3, amd64)...
Oh, and @j4cbo : I'd still be very interested to see your descriptor tables and/or MS OS X.Y descriptors that mad you have NCM working on Windows hosts out of the box ;)
Sorry for the spam today but I got it working :+1:
The problem was that I copied the ms_os_20 descriptor table from https://github.com/hathach/tinyusb/blob/master/examples/device/webusb_serial/src/usb_descriptors.c#L169 and just replaced WINUSB with WINNCM. However, then of course it still referenced ITF_NUM_VENDOR (which was defined in my code since I wanted to use WebUSB's "landing page" feature) but was of course wrong for NCM. When I replaced that with ITF_NUM_CDC_NCM_CMD it sta...
I checked out and tried with the PR but got into lots of USB issue, and cdc_msc doesn't mounted. Same setup work with existing master though. The symptom is pretty similar when using with long usb cable: enumeration complete but further transfer got stuck, I think it is due to PHY/bus unstable, it is probably already existed in master, but pr just make the timing (race condition) right to amplify the issue.
@PanRe that is great suggestion, I need to spend more time to standardize the xfer_fifo(), there is quite some driver enhancement (for supported mcus) that we could do with it.
I checked out and tried with the PR but got into lots of USB issue, and cdc_msc doesn't mounted.
Hum... That's interesting.... I'm a little out of idea.
@perigoso Could you make a test if your board ready ?
Update: I am moving the webusb server to its own repo to free up the gh-page, it will be pointed to the example.tinyusb.org while the readthedocs will be pointed to both doc.tinyusb.org and www.tinyusb.org
Describe the PR
- update documentation to pointed to docs.tinyusb.org
- rename readthedocs.yml (deprecated) to .yaml
- change webusb-serial landing page
There is a define block at the beginning of the file that where the system clock is selected by commenting and uncommenting the correct define. Which is a design flaw in my opinion because the define could be set outside. The current design is meant to copy the file into your project and ship it with your sources. While this is not optimal I would trim do...
I am not bothered at all, I have looked a bit more closer.
That is good to hear!
You are totally right about Nuclei, they provided the N200/BumbleBee Core for the GD32VF103 to GigaDevice and kind of co-developed the firmware library. I'm not sure why GigaDevice doesn't show a bit more effort with their firmware, it is a bit frustrating.
I still don't want to force any other users to use nuclei sdk just to run the usb stack. They may already be on another platform/framework, that...
That sounds good! See my other comment for more rationale.
board is ready, just need to setup the board support, I'll see If i have some time tomorrow
I checked out and tried with the PR but got into lots of USB issue, and cdc_msc doesn't mounted.
a698dda fixed speed detection, maybe it's the problem.
Otherwise I'm a little out of idea...
I've tried self/bus powered, low/high optimization, with/without RTT logging...
@perigoso Could you make a test if your board ready ?
Perfect, this fixed the issue with my set up, work g...
Supreb! Thank you @HiFiPhile for putting more effort to improve this port. This will allow adding more port using same controller easier in the future. :tada: :tada:
Describe the PR
Current poll mode speed down net throughput, we can add a api for xmitting status cb,
application can be blocked to wait usb idle.
That is good to hear!
You know this much better than me, there is obvious reason why you prefer the nuclei sdk
You are totally right about Nuclei, they provided the N200/BumbleBee Core for the GD32VF103 to GigaDevice and kind of co-developed the firmware library. I'm not sure why GigaDevice doesn't show a bit more effort with their firmware, it is a bit frustrating.
Yeah, I figured it out, Giga doesn't spend much effort like ST do with their stm32
But by doing so we have a ...
I actually take this back, given the fact that nmsis requires firmware lib modification and couldn't work with official lib downloaded from Giga. Since it is simple enough, probably only ECLIC_EnableIRQ/DisableIRQ(), do you think we could do it with register level, I actually have to go this low for some of mcu ports to stay independent enough.
I agree, having manually def/undef clock selection is a really bad design, they can just wrap them around #ifndef or simply parameterize it will make thing more portable any easier to upgrade. So yeah, I totally agree with your choice here.
@hathach Hello, could you consider of this PR?
This is absolutely possible! Enabling and Disabeling the IRQs is a simple setting and clearing the MIE bit in the mstatus register. I'll figure out if we go with the gd32vf103 firmware library provided functions or some inline asm.
That sounds good to me! I'll change the implementation to meet these constraints, maybe the core code in src can even be implemented without any reliance on any gd32vf103 firmawre library or nmsis/nuclei-sdk.
Oh except for actually enabling and disabling a specific IRQ, but this is rather easy to do.
Eh, Tried to test but the microchip submodule is still missing cmsis for the sam S 70, so i didnt bother
Thanks for patiently following my suggestion, yeah, the example bsp is mostly for demonstrating/testing and maintaining. If nuclei-sdk make it easier for us, no problem at all, I wasn't sure before and kind of worry it will become an dependency due to the nmsis. If we could get it dcd_synopsys neutral then that would be no problem.
Thank you, we only need to specifically enable/disable the USB IRQ only, and don't need a generic function like NVIC. And bit set/clear with correct mask and register would do the trick hopefully
Please have a look at https://github.com/hathach/tinyusb/pull/959/commits/c6d495d6436c797b4efd029bd16ee8f19ff0a9f0 this is the commit that removes any external dependency for the core code. Are you fine with helper functions being directly in the driver code?
Perfect! I have cleaned up and fixed a bug with the systick timer not beeing reloaded. I decided to go with nuclei-sdk inside bsp for obvious reasons ;-). Let me know what you think!
Hi @PanRe @kasjer could you get in touch with me? Looking for USB Audio Class 2.0 Developers for some contract work davide.bortolami@thinksmartbox.com
Driver support for STM32L151, changes made:
- Enable USB D+ PU
- Add en/disable low priority USB IRQ
- PMA_LENGTH 512 + stm32l1xxx driver includes
Tested with midi example.
Operating System
Linux
Board
Raspberry pi pico
Firmware
All example files
What happened ?
I tried building the example files according to the getting started guide. I copy-pasted all commands, choosing raspberry_pi_pico as BOARD. The build failed. Everything worked well when I chose feather_nrf52840_express as BOARD.
How to reproduce ?
Follow the steps in getting started guide and choose raspberry_pi_pico or pico_sdk as BOARD
Debug Log
**_../examples/device/...
I have both the TM4C1294 board and the MSP432E board, and I'm happy to help with the port. The chips use the Synopsys USB module. They support High Speed USB with an external ULPI PHY.
@KarlK90 everything look great with latest commit, however, when I tried to flash your pr to my longan nano board, it does not seems to run at all. Maybe I haven't done it correctly,
- I tried with both your recommend toolchain from embecosm and nuclei toolchain from https://nucleisys.com/download.php .
- use dfu-util (
flashtarget) to download firmware, and press reset button to reboot it.
$ make BOARD=gd32vf103_longan_nano all
text data bss dec hex filename...
which pico-sdk you are running, if it is not latest 1.2.0, please update it.
Superb!! Thank you very much of the PR and figuring this out. STM USB IP is implemented a bit different across mcu. This will help lots of other L1 user.
indent is off but this is so minor, I will fix this later on when having chance.
@KarlK90 everything look great with latest commit, however, when I tried to flash your pr to my longan nano board, it does not seems to run at all. Maybe I haven't done it correctly
Great that my changes look good.
I think the flashing problem is connected to the buggy GigaDevice DFU bootloader that reports a transfer size of 2048 bytes, dfu-util versions 0.10 or the current master branch use the correct size of 1024 bytes. My suggestion is to confirm that the dfu-util version does ...
Maybe it is not the best approach to skip closing EPs for ISO stuff completely! This would prevent users to reduce the required EP size (by reducing the sample rate or the resolution) dynamically e.g. when some other EP needs to be opened. The UAC2 spec specifically mentions this kind of flexibility. I am quiet aware this is rarely used but right now it is possible to do so.
Can the DCDs of such devices not take care of this special requirements on their own? I admit there are some ideas r...
Ah you are right, upgrading to dfu-util 0.10 and it successfully flash the device (even tried to force the upload-size with 1024 on 0.9 just to test, but it doesn't help). Thanks for suggestion, I will wire up to use it with jlink for faster developement.
The cdc_msc example have the cdc echo fine, however, the msc does not, I hook it into analyzer. Look like there is some issue when host read 4k of data. Notice that the data is corrupted with 0x55AA repeatedly somehow. Host give up a...
Good to hear that the upgrade solved the problem with the flashing.
You are right about the timer, I set the wrong reload value. The systick timer is driven by the AHB clock divided by 4. On the current implementation the AHB clock should equal the system clock (72Mhz by default). I quickly pushed a fix, hopefully that corrects the blinking frequency.
Thank you for the debugging effort, you clearly have tools and knowledge that I lack :muscle:. The tinyusb HID examples worked fine from ...
I'm sorry, I wasn't running the latest SDK. After upgrade, it works. I just didn't see pico SDK 1.2.0 as a requirements, so I didn't bother upgrading.
Describe the PR
- HIDAPI requires dummy 0x00 as reportID for single report hid device.
- Force hid_test js/py script to always do this. also update boards.js to allow specify all productid with 0xFFFF.
yeah, both HID and CDC with example config only send up to 64 bytes per fifo, this issue probably only happens when doing large buffer transferring back to back, may involve race condition. Will troubleshoot it later on.
need time to revise this, please be patient :)
@Novakov I am sorry for mistaking gdvf103 (rsicv) for the gd32f103 (m3). Apparently you are spot on, the risc v version use synopsys driver there is on-going PR to add support for vf103 that you may be interested in #959
Thanks for your willingness, there is an issue for generalizing synopsys driver to make it easier to integrate to new port #382, however, I haven't got time to do any progress yet for you to test with.
[hathach/tinyusb] New branch created: fix\-newline\-keycode\-usage
Describe the PR
HID_KEY_RETURN (0x9E) is not correct one, originally from https://github.com/adafruit/Adafruit_TinyUSB_Arduino/pull/118
[hathach/tinyusb] Pull request opened: #1013 dcd\_da1469x: Use mcu\.h instead of MCU specific header
Describe the PR
dcd_da1469x can work with broader range of MCUs that
share same USB core.
Specific header file that was used DA1469xAB.h now it is changed
to mcu/mcu.h which includes actual MCU specific register file.
Additional context
No change in code.
Only possibility to build with for other MCUs that have different name
of register file.
Port to the "new" STM32G4 Family
like NUCLEO-G431KB (...but it has no USB-Conn)
synopsys or fsdev ?
thank for the PR, I am currently busy with other works, I will try to review this as soon as possible. Please be patient
look good, thanks for the update
Describe the PR
For salf-powered code should handle VBUS changes.
Function tusb_vbus_chaneged() was present but not used in bsp;
dcd_connect() was called only at startup which is fine for
bus-powered devices.
If device was self-power and started without VBUS present
some registers would not be correctly set.
Now tusb_vbus_changed() is called whenever actual change on VBUS
is detected starting and stopping USB state machine.
Additional context
Tested only with da1469x_d...
@hathach could you please shortly outline what is correct way to handle build of board_test example that I guess does not pull whole driver part since it fails to link function tusb_vbus_changed() that is in same file that has dcd_int_handler() which does not seemed to be missing.
After some user input I received, I'm going to modify this so VBUS detection will be an option and not necessity.
After inspecting history I decided to abandon in this form.
I will prepare another PR with VBUS handling that is more in sync with all other drivers.
Operating System
Windows 10
Board
custom board with stm32f103c8t6
Firmware
examples/device/cdc_msc, but adopted manually for keil project with --gnu compiler option
What happened ?
When project is builded by keil armcc compiler, enumeration fails. The reason is a weak attribute in dcd_edpt0_status_complete function definition (dcd.h, string 135). The armcc compiler ignores function implementation in dcd_stm32_fsdev.c, and because of that device address is never actually...
Describe the PR
For self powered device if device started without VBUS present
it would not be correctly attached to USB bus even if tusb_vbus_changed()
was later called.
This modifies dcd_init() so it starts USB state machine without checking
if VBUS is present or not, like all others drivers do.
tusb_vbus_changed() function is also removed its content was moved to dcd_init.
Additional context
VBUS connect/disconnect handling similar to what is done in NRF5x maybe
do...
Describe the PR
This PR update rp2040 devvice
- Add supsend and resume support, comment out disconnection interrupt since it is not detectable since we are forcing vbus detect
- comment / whitespace / clean up dcd rp2040 e.g stall / clear stall
- reset all endpoints upon bus_reset (previously only allocated once per power), however, device can dynamically change its configuration. It is better to enumerate with a clean state.
hopefully fix https://github.com/adafruit/circuitpytho...
Hi, I am trying to work with TinyUSB on the Feather M4 CAN so that it shows up as an MSC device. I have the ramdisk example running, but I was wondering if there was a way to change the name of the drive when it is mounted to the computer. Currently it is "TinyUSB MSC" and I don't see and commands to change it on the device. Any help would be appreciated!
Your How to reproduce is not reproducible. You need to make sure others can actual reproduce what you are doing. At least
- Attach your keil project, also tell people where to put it in order to compile.
- I don't why keil didn't pick up that weak function. There is several other weak funcs which are seem to be fine. Maybe you should raise this issue in keil forum.
I haven't tested this yet, but It looks good to me. Some MCUs will have issue keeping up with high speed rate. When more mcus join the low-bitrate club we will try to make it look more elagant.
I am totally OK with changes, though would it increase the power usage since USB PHY is now enabled even without attaching to a host. I am not familiar with DA1469x enough to tell, though on nRF5x (which is also BLE mcu), which has its own off the standard API for managing power event ( vbus detect, ready, removed)
https://github.com/hathach/tinyusb/blob/master/src/portable/nordic/nrf5x/dcd_nrf5x.c#L839
It will only enabled USB peripheral and highspeed clock when vbus is stable (ready) a...
@hathach I think we could merge it like this for now. I will prepare VBUS handling since users will want to use power saving but for now it is more important to have USB working when it was not present on reset.
I already had something working to detect VBUS. In my first attempt I used dcd_connect/dcd_disconnect when VBUS was detected/lost (I think it worked). But then I was not so sure if this is correct way do handle this.
Maybe tud_connect and tud_disonnect are meant for application le...
Ok, sorry for this. I've created a repo with working project.
How to reproduce:
- git clone https://github.com/NikitaKhalyavin/tinyusb_stm32f103_test_in_keil
- cd tinyusb_stm32f103_test_in_keil/
- git submodule update --init --recursive
- open usbTest.uvprojx in Keil
- build and run on bluepill board - this causes enumeration error
- rebuild with removed weak attribute in function dcd_edpt0_status_complete definition (file tinyusb/src/device/dcd.h) and rebuild - this works correc...
Compiler armcc v5.06 update 1 (build 61)
Good to know you have plan for the vbus detect. It also buy time for me to also try to gather my thought and come up with an decent API and usage for it as well.
Describe the PR
dcd_set_address() is broken when called more than once, e.g. when plugging in the device into a different port. The problem is that it only sets new bits in the register, it doesn't clear any. Setting addres 1 followed by address 2 therefore causes the address to be set to (1|2) = 3.
Yeah, right, this is spot-on, it may be related to several other issues with unplug/re-plug stm32 (may solve issue #179). Though I think we should also clear the DAD within the bus_reset() as well to make it consistent. Since it is an easy change, I have already push the commit to your fork. Thank you for the fix.
Thanks for the merge! I did notice several more places that looked very suspicious. I plan to go though it from top to bottom, but it may take a while before I get to it as I have a big deadline coming up.
I am the one to say thank, looking forward to your PRs
Oops, this was my bad. It's been there since the beginning. Thanks @tringis for finding this :)!
Oops, this was my bad. It's been there since the beginning. Thanks @tringis for finding this :)!
No worry, I have tons of bug all over the places as well ๐ ๐
@KarlK90 Thank you very much for the PR and your patient. I have spent an hour or so trying to see if I could spot any obvious issue. Unfortunately, I couldn't, it may need a overall revise of the dcd. which I don't have the bandwidth to do at the moment. It is relatively normal for an new port, I have to do something similar with esp32 (also using synopsys IP). Therefore I think it is best to merge this to master and then file an issue so that other people can get on helping to resolve this...
Operating System
Linux
Board
Sipeed Longan Nano
Firmware
examples/device/cdc_msc
What happened ?
The cdc_msc example have the cdc echo fine, however, the msc does not, I hook it into analyzer. Look like there is some issue when host read 4k of data. Notice that the data is corrupted with 0x55AA repeatedly somehow. Host give up and decide device isn't properly formatted. It is probably buffer/endpoints config/overflow issue etc .. which is typical for a new port ba...
@hathach Thank you for you continued effort and merging this PR, the changes look good!
Hopefully the bug with the dcd and this particular peripheral is not to complicated so it can be resolved in the future. I'll try to poke at it a bit, maybe I can find something.
I am the one to say thanks, will definitely try to solve it in the future.
[hathach/tinyusb] New branch created: nrf\-suspend\-resume
Describe the PR
- Fully implement suspend, resume and remote wakeup for nrf5x.
- USBD will exit suspend mode when SOF is received for mcu that does not detect end of remote wakeup (1-15ms).
I just tested the bugfix from #1021 with a simple CDC application on a custom STM32F105 hardware.
Using the last commit 89e4586 before bugfix led into the known behavior which stopped the CDC class to work after a few reconnections.
Using the commit 48f17ef just after bugfix has always been stable to me. Even after 30 reconnections everything worked fine. Same positive behavior with the current master of course ๐.
Just tested your changes and it works fine as expected. Maybe the return value could be changed: return pbuf_copy_partial(p, dst, p->tot_len, 0);
What do you think about it?
Since pbuf_copy_partial returns 'the number of bytes copied, or 0 on failure' it might be more logical to return this value instead of always p->tot_len.
G4 family should use fsdev drivers.
I'm not sure if it helps to add a board which does not support USB as it is. But if you try to implement G4 into fsdev dcd, I could test it with a custom hardware.
That makes sense; I have added a commit that does just that. Thank you for the review and the suggestion!
Describe the PR
DCD buffer copy doesn't work correctly with IAR, after investigation IAR use optimized STM/LDM instructions in memcpy but there must be some access restrictions on USB buffer just like STM32 fsdev.
Use byte copy just like StdDriver.
thanks @duempel for testing this out, I think we could probably close this issue for now. Should it still be an issue, we could re-open it later on.
thank @majbthrd for the PR and @duempel for reviewing. It looks good.
to be honest, I feel a bit odd about this change, would it work if we cast the buffer with volatile uint8_t* instead of uint8_t*
[hathach/tinyusb] New branch created: add\-hid\-boot\-example
Describe the PR
- Add new hid boot interface example to demonstrate using boot interface with boot keyboard and boot mouse.
Note: I don't have an true bios to test with, if anyone could try it out, that would be great.
volatile doesn't work as Error[Pe167]: argument of type "uint8_t volatile *" is incompatible with parameter of type "void *"
In fact read setup packet from buffer with memcpy (LDM instruction) works, only write doesn't work.
I read the manual, it didn't mention the access type.
[hathach/tinyusb] New branch created: suspend\-resume\-followup
Describe the PR
follow up to #1023 , while unplugging, the bus condition is not stable, suspend (bus idle for 3ms) and/or resume event can be accidentally triggered by hw detection e.g suspend -> resume -> unplug . This PR skipped suspend/resume handling if not connected i.e unplug is detected and suspend/resume is not handled yet. Not perfect, but reduce noise to application.
I checked the manual as well, it is not mentioned. But It is very likely that USB SRAM is byte access. So yeah, this PR is spot on and needed.
https://github.com/majbthrd/nuc_driver/blob/master/nuc126/StdDriver/inc/usbd.h#L524
Only 1 request, would you mind adding an comment at this line and usb_memcpy below to explain the reason something like although it is not mentioned in manual, but the USB SRAM seems to only support byte access and memcpy could possibly do it by words etc ...
minor but maybe make this function inline
Describe the PR
The same logic regarding the resume signal was implemented by usbd.
See also: #1023
Additional context
I have confirmed the patch works hid_composite example on rx65n_taget.
Hello
I join the request.
We need a good library to support a PS4 Pad for Rp pico with Bluetooth support.
A library that supports more than just buttons, but also colors and vibration.
I was about to start writing one, but I have no idea about tinyusb, I just tried to learn something, but at the moment I have no knowledge to write such a library with HOST USB and BT support.
great thanks, I was wanting to do this as well as follow up, since #1023 is focused on nrf. Though I think we should only enable SOF when suspended and disable it afterwards. The reason is that SOF is currently not used at all by USBD https://github.com/hathach/tinyusb/blob/master/src/device/usbd.c#L1082 didn't submit the SOF event to usbd task queue. The reason is that I am not entirely sure if SOF is really needed for driver, mostly only audio/video where it has strict timing constraint wit...
Is your feature request related to a problem? Please describe.
Nuvoton DCD for NUC120 and NUC121 look similar enough and should be merged together to make it easier to maintain if possible.
I realized that dcd nuc120 is very similar to nuc121, and therefore also apply the same changes to it as well. This should be ready to merged once ci passed.
PS: due to the dcd similarity, I open #1029 as reminder to merge them together to make it easier to maintain in the future.
I've spotted another issue of device stopped functioning after PC reboot with set address failure.
Clear assigned_address in dcd_reset() maybe fixed it but not well tested.
assigned_address can actually changed to use the dcd_edpt0_status_complete(). other port also use this for set_address(). I think the API is added after the nuc port. I could do this but I need to find the nuc board in my drawer first :D
Re: "I don't have an true bios to test with, if anyone could try it out, that would be great."
-> I tested on different hardware and confirmed keyboard and mouse both worked in a CSM BIOS.
-> I tested on different hardware and confirmed keyboard and mouse both worked in a CSM BIOS.
Thank you for testing it out on that many platforms. getting merged now
this change is not allowed, tud_task() should be running on its own thread. Please check out other freeRTOS example for reference.
Sorry for the wait, I have tried to compile and flash this PR to saola_1 board. It shows up as network interface (great works). However, I couldn't access the webserver at 192.168.3.1 . I have checked the modification, unfortunately, I am not too familiar with esp network stack to notice any obvious issue.
I agree with the approach using esp native stack API, which is most people would do. However since it is not compatible with other port which use generic lwip. I think it is best to mak...
should be reverted, checkout other freertos example for adding include path for esp32s2
I agree with the approach using esp native stack API, which is most people would do. However since it is not compatible with other port which use generic lwip. I think it is best to make this as spin-off example as
net_esp_webserverand leave the existing example as it is.
I agree with @hathach here :) ESP should have it's own example. It will not mix with the other MCUs (which do not include LwIP in their SDK) and also make the ESP support much cleaner.
[hathach/tinyusb] New branch created: merge\-waveshare\-h7
Describe the PR
Follow up to #980, added as waveshare_openh743i_2 under h7. Will rename and remove existing one once verified working. @BennyEvans would you mind testing it out on your board, take your time, there is no hurry.
make BOARD=waveshare_openh743i_2
OK. I understood that in the current usbd, SOF events are only used for resuming. I will try if SOF events can be enabled during suspended only.
[hathach/tinyusb] New branch created: improve\-host\-stack
Describe the PR
general improvement for usbh, improve configuration parsing
Describe the PR
- Use
dcd_edpt0_status_completeto set address. - Disable SOF interrupt.
Operating System
Linux
Board
Custom board with ULPI PHY and STM32H730
Firmware
cdc_dual example, with these changes:
- with only one CDC enabled
- loopback code disabled
- Instead of looping back data from host back to host, device transmits data periodically since boot
- CDC buffers raised to 4 kiB
tusb_init();
auto prev = ticks; // ticks are volatile variable incremented every 1 ms (systick).
std::uint8_t data = 0;
for(;;) {
tud_task();
const a...
You could try to capture USB traffic with Wireshark.
From the log there are OUT transfers came from PC, or the USB transfer complete interrupt was falsely triggered.
Please put long log as attached txt file to make issue easier to read
Operating System
Windows 10
Board
Custom NUC126
Firmware
In loop:
uint8_t data[64];
if(tud_vendor_write_available() >= sizeof(data))
{
tud_vendor_write(data, sizeof(data));
}
What happened ?
This could happen on CDC & Vendor class which use fifo when USB is re-plugged.
Take Vendor class as example, fifo is cleared in vendord_reset when re-plugged, if fifo is fully written between vendord_reset and vendord_open, it will...
Describe the PR
- Fix vendor fifo deadlock in #1040
- Add tud_vendor_n_read_flush
look great, thank you for your PR.
@hathach I'll take a look and test on the weekend.
@hathach I'll take a look and test on the weekend.
thanks, take your time :)
I am porting tinyusb to the USB IP 'musbfdrc' from Mentor Graphics .
musbfdrc deals with the control transfer in a slighly different way that it needs CPU to explicitly denote a packet if it is the last packet of the transaction.
musbfdrc_ep0.pdf
Here is a brief introduction about what the CPU needs to do when dealing with control transfer. We can see that during IN DATA PHASE, when we put the last packet into the FIFO, w...
when we put the last packet into the FIFO, we must set DATAEND bit.
you can detect that by using the xfer length of the dcd_edpt_xfer(). Maybe I miss something, would mind illustrate the issue you are having with the pseudo code based, with comment what is your issue, which info is missing. It is much easier to discuss over actual work.
I guess that total_bytes is always less than or equal to max_packet_size in control transfer. https://github.com/hathach/tinyusb/blob/master/src/device/usbd_control.c#L89
But, if dcd layer can read setup packet, it can check wLength of setup packet and calculate how many interrupts will occur in the current transfer. I think a typical dcd can read setup packet.
[hathach/tinyusb] New branch created: more\-host\-improvement
Related, though perhaps not exactly the same, it would be nice if tud_task() was safe to call from multiple RTOS threads.
I have an application that does USB audio, which requires that the UAC2 driver be pretty responsive with low latency. The same same application also handle vendor requests on endpoint 0 inside tud_vendor_control_xfer_cb(). Responding here can be slow, and can cause tud_vendor_control_xfer_cb() to block for several milliseconds. While it is blocked, the audio endpoint tr...
Describe the PR
- sepearate CFG_TUH_DEVICE_MAX and CFG_TUH_HUB
- separate dev0 from _usbh_devices pool to save sram
Additional context
If applicable, add any other context about the PR and/or screenshots here.
Adding support for K32L2B
This builds on the KL25Z and RT10xx support and uses the existing mcux-sdk submodule.
thank you for the PR, I don't have this board to test with, but it looks good for the merge
Describe the PR
- Add host hid_controller example tested with Sony PS4 Dualshock controller
- Add tuh_vid_pid_get()
- Rename host API to be consistent with naming on device stack
- tuh_device_get_speed() to tuh_speed_get()
- tuh_device_configured() to tuh_mounted()
- tuh_device_ready() to tuh_ready()
Operating System
Windows 10
Board
Feather M0 with added flash and battery including switch
Firmware
/*********************************************************************
Adafruit invests time and resources providing this open source code,
please support Adafruit and open-source hardware by purchasing
products from Adafruit!
MIT license, check LICENSE for more information
Copyright (c) 2019 Ha Thach for Adafruit Industries
All text above, and the splash ...
please post your sketch as attached file for readability. Also I cannot reproduce your issue, since I don't have the MX25L25673G device. Please try to reproduce it with one of the Adafruit board without any hardware modification.
host hid controller is added with ps4 dualshock support here https://github.com/hathach/tinyusb/pull/1047 .
video demo https://twitter.com/tinyusb/status/1430406301553594372
For more advance feature e.g set LED. vibrate motor etc check out linux driver for hint https://github.com/torvalds/linux/blob/master/drivers/hid/hid-sony.c
I will close this issue for now, midi host driver will take very long time since there is no plan (and no time) for it at the moment.
I have updated 1st post to make it easier to follow. but I still cannot reproduce your issue due to your sketch using additional flash device that I don't have. Can you try to reproduce this on one of adafruit M0 board that has on-board flash and update the sketch accordingly.
Added support for Microchip Curiosity Nano SAMD21 board (DM320119) under hw/bsp/samd21/boards/curiosity_nano
The nEDBG on this board requires dap_protocol be specified as SWD (changed in examples/rules.mk)
NOTE: requires entry (03eb:2175) for VID:PID of nEDBG be added to /etc/udev/rules for pyocd
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.
tud_task() is safe to called from RTOS as long as osal mutex is implemented. tud_task() essentially get event from rtos queue to process. This issue is more about MCU with multiple cores running on bare metal (no RTOS) and 2 cores can potentially cause race condition to each other. Btw which RTOS you are running.
Note: current vendor driver isn't thread safe , which is mentioned here. https://github.com/hathach/tinyusb/issues/900#issuecomment-870261839 Therefore it could be an issue, I wi...
thank you for your PR, there is an existing samd21 family in the bsp/samd21, can you add it using board header and board.mk similar to other boards in the same family
https://github.com/hathach/tinyusb/tree/master/hw/bsp/samd21/boards
Thank you look good, note vendor driver is lacking behind and is not thread safe if you are using rtos https://github.com/hathach/tinyusb/issues/900#issuecomment-870261839
The changes were made under bsp/samd21
All changes were based on existing board as a template.
Do you want to add tud_cdc_n_write_flush in cdcd_open ?
Here is a new msc_sdfat_bug.ino sketch and a new set of results run against an Adafruit Feather M0 Adalogger with a microSD card inserted. The sketch is based on the msc_sdfat.info sample.
Results follow the same naming convention as above. The results are almost al...
Operating System
Windows 10
Board
STM32F103BluePill
Firmware
Stock firmware example for stm32f103bluepill. HID example. File in question is usbd.c.
This is an uninformed guess, but if the Assert is removed, the test passes. I apologize if I don't understand the care and feeding of TU_ASSERT.
case TUSB_REQ_SET_CONFIGURATION:
{
uint8_t const cfg_num = (uint8_t) p_request->wValue;
// GB: if ( !_usbd_dev.cfg_num && cfg_num ) TU_A...
Operating System
Others
Board
Raspberry Pi Pico (RP2040)
Firmware
examples/host/hid_controller
Cloned from current tinyusb 'head' on August 25
Used in conjunction with current release of pico-sdk (1.2.0)
What happened ?
Tested with 2 controllers; results are as follows:
- Hori HORIPAD mini4 was enumerated/identified as VID = 0f0d, PID = 00ee, but example did not respond to any controller actions or button presses
-> Modifying src/hid_app.c ( function 'is_sony_ds...
most of other adafruit has external flash on board, is your Feather M0 an non-express version without spi flash on it ? Do you have any other M0, M4 board to test with.
Do you want to add
tud_cdc_n_write_flushincdcd_open?
it may not be needed, can you reproduce the issue with cdc ?
The changes were made under bsp/samd21
All changes were based on existing board as a template.
ah right, sorry, It is my bad, my brain didn't function well last night (probably due to lack of sleep).
it may cause issue with other boards (not all use swd). We should have an PYOCD_OPTION which is default to empty. What do you say ?
we may not force the protocol for all other boards. I think it is best to have PYOCD_OPTION variable similar to the JLINK_IF above, which default to empty and is set by samd21 nano in its board.mk
PYOCD_OPTION ?=
PS: most of official sam board can be flashed with edbg, you may want to check it out # flash using edbg from https://github.com/ataradov/edbg
# flash using edbg from https://github.com/ataradov/edbg
flash: $(BUILD)/$(PROJECT).bin
edbg --verbose -t same54 -pv -f $<
``
thank for your PR, I am able to reproduce the issue. The configuration switching requires an extra works with additional dcd API to make sure it is working correctly. Although it is possible to cheat the test since we only have 1 configuration, it is still better to implement it properly. I will try to get the stack fully passed the USBCV compliance test asap, so stay tuned.
PS: I did fixed an TD 9.4 test as well which is easier.
[hathach/tinyusb] New branch created: usbcv\-compliant\-test

This is my implementation.
But there is a risk. If the total length of DATA PHASE is just 64, there might be only one 64 byte-packet. In this circumstance, this code cann't set DATAEND bit correctly.
@zxtxin when the dcd_edpt_xfer() is called with 64, it means there is only 64 bytes, and you must set DATAEND bit. DCD aren't allowed to add ZLP, if an ZLP is needed dcd_edpt_xfer with an length of zero will be called afterwards.
getting it passed for now with a new empty API. There is a really stretch test with 150 enumerations with CV, really nice thing
Now Starting Test: TD 9.16 - Enumeration Test(repeat 150 times)
Start time: Aug 26, 2021 - 17:13:02
Device speed is Full.
Beginning enumeration test with 150 enumerations. This may take several minutes to complete.
......................... 25 enumerations
......................... 50 enumerations
......................... 75 enumerations
...............
Updated the PR with your 'PYOCD_OPTION' suggestion - great idea (I figured a global change like that would be an issue).
For what it's worth, I reported the issue with nEDBG not responding to correctly unless the protocol was explicitly set to swd. The maintainer was 'surprised', but just figures it's a bug in the implementation with that specific device (nEDBG has different USB PID than EDBG).
Thanks for the tip re:ataradov/edbg. Will check it out at some point, but since your projec...
most of other adafruit has external flash on board, is your Feather M0 an non-express version without spi flash on it ? Do you have any other M0, M4 board to test with.
Correct, the Feather M0's I have are the non-express version that does not have external flash. I believe the first firmware above should work with minor modifications to point at the on-board external flash.
it may not be needed, can you reproduce the issue with cdc ?
If the user protocol is character based it won't be needed since buffer will be flushed at next write.
But if the protocol is packet based it could happen, same as I experienced in vender class.
void main(void)
{
board_init();
tusb_init();
while(1)
{
tud_task();
cdc_task();
}
}
typedef struct
{
char text[40];
uint32_t a;
uint32_t b;
}Status_t;
Status_t...
Describe the PR
A few minor changes to the language.
Thank you for your hard work and time! It is a nice tool. Just a heads up, I also will be running the HID View test as well.
chapter 9 and hid test is all passed ( i am testing on nrf52840), trying to get it passed msc just now https://github.com/hathach/tinyusb/tree/usbcv-compliant-test
@zxtxin
Why not check wLength of a setup packet in order to know the actual total length requested by the host of each transfer.
My understanding, only the last packet of a data stage should be set DATAEND bit. If it true, I guess wLength should be check.
For example, net_lwip_webserver log is shown below.
USBD Setup Received 80 06 00 02 00 00 4B 00
Get Descriptor Configuration[0]
Queue EP 80 with 64 bytes ...
USBD Xfer Complete on EP 80 with 64 bytes
Queue EP 80...
@proppy we can close this, right?
There were two issues:
- Indeed the TinyUSB examples do not work on Fomus with an older (v1.9.1) bootloader, but do work with the current v2.0.3.
- Some paths/filenames have changed; @proppy updated them in the Fomu Workshop documentation.
Great job! And fast. I think it will be a badge of honour to add this to your features list. A new bullet point. :-)
Yep, those were likely due to an outdated bootloader as you pointed out in https://github.com/im-tomu/fomu-workshop/issues/519
Describe the PR
The _stridx of bth interface is wrong.
@zxtxin
Why not checkwLengthof a setup packet in order to know the actual total length requested by the host of each transfer.
My understanding, only the last packet of a data stage should be set DATAEND bit. If it true, I guesswLengthshould be check.For example,
net_lwip_webserverlog is shown below.USBD Setup Received 80 06 00 02 00 00 4B 00 Get Descriptor Configuration[0] Queue EP 80 with 64 bytes ... USBD Xfer Complete on EP 80 with 6...
@zxtxin when the dcd_edpt_xfer() is called with 64, it means there is only 64 bytes, and you must set DATAEND bit. DCD must not add ZLP, if an ZLP is needed dcd_edpt_xfer with an length of zero will be called afterwards.
For GET_CONFIGURATION request, usb device often send more than 64 bytes to EP0_IN endpoint. For example, the length is 80 bytes, tinyusb will call dcd_edpt_xfer(64) for the first time and then call dcd_edpt_xfer(16). So the DATAEND bit should be set at dcd_edpt_xfer(16)...
But now there is no API that I can use to get wLength.
@zxtxin
I think you can get wLength without any API.
A typical USB controller has dedicated registers to indicate whether a received packet is a setup packet or not. dcd layer, when it receives a packet, checks the dedicated register to detect whether the packet is a setup packet or not. If the packet is a setup packet, dcd layer has to call dcd_event_setup_received to pass the setup packet into usbd layer.
At that point, you ...
But there is a risk. If the total length of DATA PHASE is just 64, there might be only one 64 byte-packet. In this circumstance, this code can't set DATAEND bit correctly.
Your implementation is totally ok, if the DATA PHASE length is 64 bytes USBD layer will send another ZLP packet.
So with ZLP packet last = true and DATAEND is set.
There is no need to read wLength.
@hathach I've just tested and most seems to be working except for the FreeRTOS example. I believe you still need SysTick->CTRL &= ~1U; at the beginning of the initialisation to ensure you don't enter the systick ISR. I'm not sure if you want to add that in a broader sense or just for this board.
I haven't tested every example but have tested a few in both FS and HS. UART logging all seems to be working well. Once the FreeRTOS examples are fixed, I'll perform some more testing. My board i...
I think that when host requests a control read transfer with a multiple of 64(=max packet size) bytes length, it needs to check wLength.
In Universal Serial Bus Specification, Revision 2.0 5.5.3, data stages are described as follows.

My understanding is followings. When wLength is greater than the actual data size and is a multiple of 64, USBD layer needs to send ZLP. ...
My understanding is followings. When wLength is greater than the actual data size and is a multiple of 64, USBD layer needs to send ZLP. When wLength is equal to the actual data size and is a multiple of 64, USBD layer does not send ZLP.
You're right.
Sorry I missed out that no ZLP is sent on data stage if length is multiple of 64.
https://github.com/hathach/tinyusb/blob/8d97f0e81f775d8c7646dfc75ee59b7e938bbf8d/src/device/usbd_control.c#L197
pins::LedErr.setLevel(true);
it is not buildable, please also give the link to your fork that contain the exact code, it must be as minimal changes as possible.
great, this is spot on, thank you for your PR.
@zxtxin please follow the suggestion from @kkitayam to store the wlength and direction if DATA in, or you could keep an copy of 8-byte setup packet. It totally depends on your port. It is too specific with your port to have an dedicated API for it.
Thank you @BennyEvans for testing this out, yeah you are right, it is best to explicitly disabled systick to prevent its ISR triggered before scheduler start. It should be done for other family as well, but it is less of an issue since most of them board_init() finishes fast enough before the tick expire. I have expanded this to other stm families, should do for all, but I will do it gradually later on.
From your testing feedback, I think the PR is good for merged, no need for further tes...
thank you for your PR, I did fix building with CI (make MSC readonly, skip net webserver examle)
and rebase (since master has changes a bit). Will be merged when ci passed.
@zxtxin please follow the suggestion from @kkitayam to store the wlength and direction if DATA in, or you could keep an copy of 8-byte setup packet. It totally depends on your port. It is too specific with your port to have an dedicated API for it.
OK. I will follow this.
[hathach/tinyusb] New branch created: release\-0\.11\.0
Describe the PR
prepare for 0.11.0 release
Describe the PR
Initial PR to get TinyUSB passed the USB complaince verification test suite (USBCV). The test suite include many corner cases which require changes to both usbd and dcd to pass. This PRs include the update to get nrf52840 ( board feather_nrf52840_express) to pass following:
- Chap9 tests suite
- HID test suite for hid_composite example
- MSC test suite for cdc_msc/msc_dual_lun examples
More PRs to get all other MCU passed test suite will follow up in the future.
...
What is this issue for
The test suite include many corner cases which require both update of usbd and dcd to pass. This issue is used to keep track of current status of compliance test of tinyusb device stack on each DCD ports. Once it is all passed, we could close this.
What is USB Compliance Verification (USBCV)
USBCV is test suite tool used by usb-if to verify all usb hardware/software/controller which is required to passed in order to have USB logo on the product. ht...
#1058 get the stack passed the 3 test suite: chapter9, hid, msc, but I only did the test and update to my frequent used nRF52840 mcu. I haven't tested the stm32f1 just yet though you could give it a try. We will eventually get there #1059 will keep track of compliance status of all ports.
@hathach good to hear. I'll be jumping back into some USB development soon so will be able to give it a thorough test then. In the meantime, if there are any discussions related to this board that you need me to help out with, don't hesitate to mention me (so that I get an email) and I can help out. Thanks for all your help.
I'm trying to test my project based on STM32L071.
SetConfiguration passed even without #1058
TD 9.13 - SetConfiguration Test (Configuration Index 0)Passed
INFO
Start time: Aug 30, 2021 - 14:23:20
INFO
SetConfiguration with configuration value : 0x1
INFO
Unconfigured the device
INFO
SetConfiguration with configuration value : 0x1
INFO
Stop time: Aug 30, 2021 - 14:23:21
INFO
Duration: 1 second.
INFO
Stopping Test [ TD 9.13 - SetConfiguration Test (Configuration Index 0...
@HiFiPhile USB 2.0 extension section 9.6.2.1 is part of USB 3.2 revision 1.0 specs
I think I'll separate this PR into multiple parts for easier review:
- Improvements for dcd_transdimension
- CDC xfer_fifo & DMA support
- Update UAC2 with dcd_transdimension
yes, please do, separate the cdc fifo expose, since I don't want to commit to have that at the moment. Need more time to evaluate the API or alternatives.
Describe the PR
Quick fix for HID_LOGICAL_MAX overflow (-1).
thanks, I didn't run cv on other example than cdc_msc and hid_composite. Group them or not isn't an issue at all. Feel free to do it in your most convenient manner.
[hathach/tinyusb] New branch created: samd\-compliance
Describe the PR
clear stall and reset data toggle when open edpt required to pass one of msc test.
