Heap not work

Share code examples or discuss embedded software, including device drivers, interrupt handlers, middleware and application code.

Moderators: Markus Girdland, Mattias Norlander

ArtemGromak
Posts: 5
Joined: Thu Mar 02, 2017 3:04 pm

Heap not work

Postby ArtemGromak » Mon Jan 28, 2019 3:28 pm

Hi.
I want to use dynamic memory allocation in my program. I generated the project in CubeMX (stm32H743), set the heap size to several kilobytes, but when I try to allocate memory, malloc always returns NULL, although there is enough memory. It turns out that CubeMx can not create the right project for TrueStudio. How can I solve the problem?
Thank.

ArtemGromak
Posts: 5
Joined: Thu Mar 02, 2017 3:04 pm

Re: Heap not work

Postby ArtemGromak » Thu Jan 31, 2019 11:08 am

An error occurs on these lines of code in the sbrc function.

Code: Select all

   if (heap_end + incr > min_stack_ptr)
   {
      errno = ENOMEM;
      return (caddr_t) -1;
   }

Then comment them out then memory is allocated.
Why it happens? Maybe something is wrong in the linker script?


Return to “Embedded target code development discussions”

Who is online

Users browsing this forum: No registered users and 1 guest