Loading...
 

Zephyr project on STM32

   Zephyr Workbench, a VSCode extension to manage Zephyr on STM32.
It enables users to easily create, develop, and debug Zephyr applications.
Main features:
  • Install host dependencies.
  • Import toolchain and SDK.
  • Create, configure, build and manage apps.
  • Debug STM32.
You can directly download it from the VSCode marketplace
For more details, visit the Zephyr Workbench

System Workbench for STM32


You are viewing a reply to Locate Heap in SDRAM  

Locate Heap in SDRAM

Tunisia

We can also do that without big modifcations in linker script biggrin

by defining the heap start/end in linker miscellaneous flags, ie :

-Wl,--defsym=__heap_start=0xD0000000,--defsym=__heap_limit=0xD0800000

Note: you have to change these values with yours

and removing heap informations from linker (not necessary but good for your linker lisibility)

1- remove this line :
_Min_Heap_Size = 0; /* required amount of heap */
2- and replace this

/* User_heap_stack section, used to check that there is enough RAM left */
  ._user_heap_stack :
  {
    . = ALIGN(8);
    PROVIDE ( end = . );
    PROVIDE ( _end = . );
    . = . + _Min_Heap_Size;
    . = . + _Min_Stack_Size;
    . = ALIGN(8);
  } >RAM

with the following

/* User_stack section, used to check that there is enough RAM left */
  ._user_stack :
  {
    . = ALIGN(8);
    PROVIDE ( end = . );
    PROVIDE ( _end = . );
    . = . + _Min_Stack_Size;
    . = ALIGN(8);
  } >RAM



Edit: I forgot syscalls modifications mrgreen

You have to add syscalls.c to project (you can borrow it from another SystemWorkbench project)
then replace _sbrk function by the following

caddr_t _sbrk(int incr)
{
	extern char __heap_start asm("__heap_start"); /* Defined by the linker. */
	extern char __heap_limit asm("__heap_limit"); /* Defined by the linker. */

	static char *heap_end;
    static char *heap_limit = &__heap_limit;

	char *prev_heap_end;

	if (heap_end == 0)
		heap_end = &__heap_start;

	prev_heap_end = heap_end;
	if (heap_end + incr > heap_limit)
	{
		errno = ENOMEM; // not enough memory
		return (caddr_t) -1;
	}

	heap_end += incr;

	return (caddr_t) prev_heap_end;
}
 

Newest Forum Posts

  1. STM32 MCU model shortlisting for Making RC remote by Palvish, 2025-07-07 15:05
  2. SPI on Nucleo_STMH533RE by royjamil, 2025-05-04 20:13
  3. SPI on Nucleo_STMH533RE by higginsa1, 2025-03-25 07:37
  4. SPI on Nucleo_STMH533RE by royjamil, 2025-03-23 11:31
  5. SPI on Nucleo_STMH533RE by higginsa1, 2025-03-23 09:33
  6. Configuring DMA for ADC in SW? by sam.hodgson, 2025-03-04 12:58
  7. Build a project in "release" mode by info@creosrl.it, 2025-02-20 18:12
  8. Build a project in "release" mode by info@creosrl.it, 2025-02-20 17:05
  9. Build a project in "release" mode by tang, 2025-02-20 10:36
  10. Build a project in "release" mode by info@creosrl.it, 2025-02-19 17:35

Last-Modified Blogs