question

ApurvaKumar-1569 avatar image
0 Votes"
ApurvaKumar-1569 asked ChaoqiongXiao-3645 answered

Provide information for recommended "Size of the regular memory pool" used in "ux_system_initialize" API for Host/ device class

I want to know how i can finalize the recommended "Size of the regular memory pool" used in "ux_system_initialize" API while using USBX Host/ Device Class in my application code . Refer below code snipet :

UINT ux_system_initialize(VOID regular_memory_pool_start,
ULONG regular_memory_size,*
VOID *cache_safe_memory_pool_start,
ULONG cache_safe_memory_size);

azure-rtos
· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Hi @ApurvaKumar-1569 , sharing with you the documentation where we showcase an example using 128k of regular memory, let me know if it helps?

https://docs.microsoft.com/en-us/azure/rtos/usbx/usbx-host-stack-2#initialization-of-usbx-resources

Thanks!

1 Vote 1 ·

1 Answer

ChaoqiongXiao-3645 avatar image
2 Votes"
ChaoqiongXiao-3645 answered

There is no easy API for memory allocation check, but there is some way to check memory usage, by checking fiedls in global _ux_system.


The regular memory passed by ux_system_initialize splits to two part: the system structures and memory pool for allocation.
So at any time the memory usage is as follow:

 ux_global_structure_memory_bytes = (ALIGN_TYPE)_ux_system -> ux_system_regular_memory_pool_start - (ALIGN_TYPE)_ux_system;
 ux_allocated_regular_memory_bytes = _ux_system -> ux_system_regular_memory_pool_size - _ux_system -> ux_system_regular_memory_pool_free;


The total usage is the sum of above two.

Thus the size of memory usage can be estimated.

Note with UX_ENABLE_MEMORY_STATISTICS defined there is another variable _ux_system -> ux_system_regular_memory_pool_min_free can be used to check max memory usage.

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.