[USB HID]Boot protocol Stack overflow

Hello ! 

I'm struggling a bit with the USB HID boot protocol, I have a lot of stack overflow error when trying to do operations while in the get_report callback.

I know that I don't have to do time consuming operations while in callback, but not so big operation will make the stack to overflow.

Is there a way of increasing this stack ? 

note: 

I kept time consuming operations for the work queue but I still have to respond in the get report callback so minor operation should be accepted.

Thanks in advance.

Martin.

Parents
  • Hi Martin

    The time spent and the stack memory used is essentially two separate issues, and you need to be aware of them both, since they are not directly related. 

    If you incur stack overflows often you might want to consider which variables you are putting on the stack and which you are not. Consider making larger arrays or structs static or global, to avoid them being put on the stack, since pushing a lot of data on the stack will also incur CPU overhead and increase runtime. 

    As for increasing the stack size I assume it is the USB_WORKQUEUE_STACK_SIZE parameter you would need to change. You could try to set this to a larger value, and see if it solves the situation.

    The default should be 1024 bytes, try larger values like 2048 or 4096 and see if it works better:

    CONFIG_USB_WORKQUEUE_STACK_SIZE=4096

    Best regards
    Torbjørn

  • Hi Torbjørn,

    Sorry I was a bit tired when opening this topic and yes your right.

    I'm already using the max stack size, the issues seems to come from my  architecture; since I'm using std::container..

    I'll see if I need to change it later.

    Thanks for the response. 

    note : It would be nice to have a larger max usb workqueue size.

    Best regards.

    Martin.

Reply
  • Hi Torbjørn,

    Sorry I was a bit tired when opening this topic and yes your right.

    I'm already using the max stack size, the issues seems to come from my  architecture; since I'm using std::container..

    I'll see if I need to change it later.

    Thanks for the response. 

    note : It would be nice to have a larger max usb workqueue size.

    Best regards.

    Martin.

Children
Related