STM32F7508 USB-Stick -> Cannot allocate memory for MSC Handle
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2022-12-07 10:12 AM
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?
Solved! Go to Solution.
- Labels:
-
STM32F7 Series
-
USB
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2022-12-09 07:05 AM
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2022-12-07 10:55 AM
What are you building with?
What size is the heap?
Up vote any posts that you find helpful, it shows what's working..
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2022-12-07 11:30 AM
I create the Gui with TouchGFX and the logic with CUBE-IDE.
The heap from what? Minimum-Heapsize ist 0x2000.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2022-12-07 12:18 PM
If these messages are coming from the F7, I'd suggest grep'ing the source and understanding the cause and context.
Up vote any posts that you find helpful, it shows what's working..
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2022-12-07 02:18 PM
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;
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2022-12-07 02:49 PM
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.
Up vote any posts that you find helpful, it shows what's working..
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2022-12-07 03:36 PM
Check how USBH_malloc is defined. It depends on some USB configuration .h file in your project. It can be mapped to malloc/free or something else.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2022-12-09 04:12 AM
In file usb_conf.h is the following definition.
/** Alias for memory allocation. */
#define USBH_malloc malloc
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2022-12-09 07:05 AM
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