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

USB host stack sizes need to be large. #21

Open
maxkunes opened this issue Jun 25, 2021 · 4 comments
Open

USB host stack sizes need to be large. #21

maxkunes opened this issue Jun 25, 2021 · 4 comments

Comments

@maxkunes
Copy link

maxkunes commented Jun 25, 2021

Hi,

It seems the default stack size for UsbX in the gnu port file is too small for even my basic application of USB mouse and keyboard. I believe it is set to 2048 by default. 8192 seems to do the trick for me. However, I can probably get away with something in the middle.

When the stack size is too small I always get a hard fault in the UX function that searches for a free memory block called by the ux allocate function. This occurs when I plug in a device for a second time. IE: plug in a device, unplug the device, and plug it back in. 100% hardfault using that scenario with the default stack size on USBx v6.1.7. I know it is a stack corruption as the local variables get corrupted and simply upping the stack size fixes the issue. This issues happens nomatter how many devices are used. It happens constantly with just a basic mouse after the second plug in.

It's not really a bug, but it seems something has changed recently, from the older versions, that are requiring a larger stack size. This is more so a note to others that might run into a similar issue.

I'm on the ARM platform using an MXRT1064

@parthindia47
Copy link

parthindia47 commented Jun 25, 2021

Max,
Is this stack size for threads or is it stack size for USBx ?

Thread size is provided here

tx_thread_create(&tx_mass_storage_thread, "tx demo", mass_storage_thread_entry, 0,
          stack_pointer, DEMO_STACK_SIZE,
          30, 30, 1, TX_AUTO_START);

USBx stack size is passed in this function call :
ux_system_initialize(memory_pointer, USBX_MEMORY_SIZE, UX_NULL, 0);

And I would be surprised if USBx stack works with 8K.

@maxkunes
Copy link
Author

maxkunes commented Jun 25, 2021 via email

@wetechautomation
Copy link

I am able to get usbx working in 20KB in host mode stack

@yuxin-azrtos
Copy link
Contributor

@maxkunes The intention is to allow developers to specify a suitable stack size in ux_port.h. Given different architectures we support, and the individual use case, its hard to set a default that is big enough but not too big to waste RAM space.

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

No branches or pull requests

4 participants