Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tud_task() hangs when there are no more messages in the buffer due to the timeout_ms value is set to UINT32_MAX. It should be 0, right? #2692

Closed
1 task done
cornedoggen opened this issue Jun 28, 2024 · 4 comments
Labels

Comments

@cornedoggen
Copy link

Operating System

Linux

Board

Custom

Firmware

custom firmware

What happened ?

when the function tud_task() is called, it will in its turn call tud_task_ext(UINT32_MAX, false). The problem with this is that if there are no more messages in the freertos queue, the timeout value of UINT32_MAX is like stay here forever.. and system hangs. I think the value of timeout could be set to 0 to immediatly return if there is no data available in the queue.

How to reproduce ?

try to comile a cdc example with stm32u5 and freertos configured.

Debug Log as txt file (LOG/CFG_TUSB_DEBUG=2)

I dont have any logs.

Screenshots

No response

I have checked existing issues, dicussion and documentation

  • I confirm I have checked existing issues, dicussion and documentation.
@HiFiPhile
Copy link
Collaborator

No, please take a look at FreeRTOS enabled examples, tud_task() is executed in it's own task, when there is no message it's blocked to free CPU.

https://github.com/hathach/tinyusb/tree/master/examples/device/cdc_msc_freertos

@cornedoggen
Copy link
Author

cornedoggen commented Jul 22, 2024

I still have to add a vTaskDelay after tud_task() function otherwise my application freezes. And what I dont understand is if the tud_task is blocking, it is consuming all cpu right?? How is it supposed to work?

@HiFiPhile
Copy link
Collaborator

I dont understand is if the tud_task is blocking, it is consuming all cpu right??

No, the task will enter blocking state when eveet list is empty, to give CPU resource to other tasks.

You can read more about RTOS https://www.digikey.com/en/maker/projects/introduction-to-rtos-solution-to-part-3-task-scheduling/8fbb9e0b0eed4279a2dd698f02ce125f

@cornedoggen
Copy link
Author

Ok thats clear to me , but why is my application only working properly with the vTaskDelay added? It should work without it right? But it doesnt. Are there other FreeRTOS config settings which can cause this behaviour?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants