AnsweredAssumed Answered

USB data buffer overlaps with stack leading to fault

Question asked by p.ben on Jan 25, 2015
Latest reply on Jan 25, 2015 by Clive One
Hi,
I am running a USB MSC project on my STM32L1 board generated using the CubeMX software.
I am noticing that during enumeration, the device receives a Read10 request for 16 blocks of data (each 512 bytes in size). I see that the pointer for the data buffer allocated for this request (and passed to Storage_Read_FS as parameter 'buf') eats into the current boundary of the stack. As a result when I write the relevant read data into this buffer it corrupts the stack, thereby leading to a fault.

I notice that when this corruption occurs, the stack is only 0x136 bytes in size whereas the size of stack that I have configured is 0x800. This makes be believe that the issue is not that the stack is too small.
Here is my stack size configuration

Stack_Size      EQU     0x00000800


I'm wondering why the location for the USB data buffer was allocated too close to the stack.
Any inputs are greatly appreciated.

Thanks,
Ben
 

Outcomes