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

Allow the use of non-static allocation for FreeRTOS mutexes & queues #1767

Merged
merged 8 commits into from Dec 5, 2022
Merged

Allow the use of non-static allocation for FreeRTOS mutexes & queues #1767

merged 8 commits into from Dec 5, 2022

Conversation

pete-pjb
Copy link
Contributor

Allow the use of non-static allocation for FreeRTOS mutexes & queues

Added some conditional code to the file src/osal/osal_freertos.h to check the FreeRTOS configuration option configSUPPORT_STATIC_ALLOCATION and if it is set to '0' We use the non-static variants of the queues, mutexes and associated creation functions.

@pete-pjb
Copy link
Contributor Author

pete-pjb commented Dec 1, 2022

Hi @hathach ,

It seems one of the CI tests is failing (Build ARM / build-arm (rp2040) (pull_request)) , I have looked at the 'Details', there seems to be no clue as to why? If I need to change something, please let me know.

Kind Regards,

Pete

@hathach
Copy link
Owner

hathach commented Dec 1, 2022

it is network/bandwidth issue, happen quite often now and then. Just re-run it.

@pete-pjb
Copy link
Contributor Author

pete-pjb commented Dec 1, 2022

Hi @Hatach ,

I have also added another 'FreeRTOS' related commit to this pull request to eliminate the need to repeatedly call the tuh_task() when using FreeRTOS. You can just start tuh_task() as a normal task from FreeRTOS like this:

xTaskCreate( (TaskFunction_t)tuh_task, "USB", THREAD_STACKSIZE, NULL, USB_PRIORITY, NULL );

This eliminates the very small overhead incurred when calling the function continuously in a loop from another FreeRTOS task which is not necessary whilst the tuh_task_ext() is being executed in it's own loop and blocking using the OS specific calls... I hope that makes sense.

Let me know your thoughts...

Kind Regards,

Pete

@pete-pjb
Copy link
Contributor Author

pete-pjb commented Dec 1, 2022

Hi @hathach ,

I have also added another commit here, I added the CFG_TUSB_MEM_SECTION macro to the declaration of struct _ctrl_xfer in usbh.c, this is required for my port also.

I hope that is okay.

Kind Regards,

Pete

Copy link
Owner

@hathach hathach left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thank you for the PR, though it is better to revert some of your recent changes.

src/osal/osal_freertos.h Show resolved Hide resolved
src/host/usbh.c Outdated Show resolved Hide resolved
src/host/usbh.c Outdated Show resolved Hide resolved
src/osal/osal_freertos.h Show resolved Hide resolved
@pete-pjb pete-pjb requested a review from hathach December 2, 2022 11:23
…ORT_DYNAMIC_ALLOCATION only

note: for example to build with configSUPPORT_STATIC_ALLOCATION = 0, one
of heap_n.c must be included in makefile/cmake
Copy link
Owner

@hathach hathach left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thank you for your PR. I have pulled and tested with existing examples on actual hardware. It worked great, I also clean up and put more update to existing examples to allow it to run with configSUPPORT_STATIC_ALLOCATION=0

@hathach hathach merged commit 71a5906 into hathach:master Dec 5, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants