Skip to main content
Visitor II
December 7, 2022
Solved

STM32F7508 USB-Stick -> Cannot allocate memory for MSC Handle

  • December 7, 2022
  • 4 replies
  • 2415 views

I have an STM32F508 board and want to connect a USB stick. However, the stick is not recognized. I get the following messages in the debug messages:

DEBUG : Cannot allocate memory for MSC Handle

Device not supporting MSC class.

Tried it with the same settings with a STM32F411 board. Here it works.

Can anyone tell me where the problem is?

    This topic has been closed for replies.
    Best answer by Roman REITER

    WTF

    When I change the definitions it seems to work.

    /** Alias for memory allocation. */
    #define USBH_malloc pvPortMalloc
     
    /** Alias for memory release. */
    #define USBH_free vPortFree

    4 replies

    Graduate II
    December 7, 2022

    What are you building with?

    What size is the heap?

    Visitor II
    December 7, 2022

    I create the Gui with TouchGFX and the logic with CUBE-IDE.

    The heap from what? Minimum-Heapsize ist 0x2000.

    Graduate II
    December 7, 2022

    If these messages are coming from the F7, I'd suggest grep'ing the source and understanding the cause and context.

    Visitor II
    December 7, 2022

    I already have. only I don't know anymore. can only be the "USBH_malloc"!?

    In the usbh_msc.c i found the message with the allocation.

     phost->pActiveClass->pData = (MSC_HandleTypeDef *)USBH_malloc(sizeof(MSC_HandleTypeDef));
     MSC_Handle = (MSC_HandleTypeDef *) phost->pActiveClass->pData;
     
     if (MSC_Handle == NULL)
     {
     USBH_DbgLog("Cannot allocate memory for MSC Handle");
     return USBH_FAIL;
     }

    Graduate II
    December 7, 2022

    Ok, so figure out what pool that's pulling from.

    If you're malloc()ing large buffers for other purposes, or that the handle is excessively large.

    Check it's using the pool you expect.

    Check if it's using _sbrk() from newlibs/syscalls, and that the heap and stack resided in the same memory region, if the code is expecting that.

    Roman REITERAuthorAnswer
    Visitor II
    December 9, 2022

    WTF

    When I change the definitions it seems to work.

    /** Alias for memory allocation. */
    #define USBH_malloc pvPortMalloc
     
    /** Alias for memory release. */
    #define USBH_free vPortFree