cancel
Showing results for 
Search instead for 
Did you mean: 

I want to move the ucHeap of the FreeRTOS from RAM_D1 to External RAM (HYPERRAM)

vishnu_illikkal
Associate III
Board Using - STM32H735G-DK

1. I tried moving the whole .bss section into HYPERRAM

  /* Uninitialized data section into "RAM_D1" Ram type memory */
  . = ALIGN(4);
  .bss :
  {
    /* This is used by the startup in order to initialize the .bss section */
    _sbss = .;         /* define a global symbol at bss start */
    __bss_start__ = _sbss;
    *(.bss)
    *(.bss*)
    *(COMMON)

    . = ALIGN(4);
    _ebss = .;         /* define a global symbol at bss end */
    __bss_end__ = _ebss;
  } >HYPERRAM  /* RAM_D1 */

 

This causes HardFault Error and the Display is a white screen.
Observation/Guess : maybe because the code that starts the board/MCU is in the bss section and the HYPERRAM is not initialized at the start so the code to initialize the HYPERRAM is inside HYPERRAM. So it is not working.

2. Moving only ucHeap to HYPERRAM

Edited the linkerscript to create a new section

.freertos_data (NOLOAD) :
  {
    . = ALIGN(4);
    _freertos_data_begin = .;
    *(.freertos_data)
    *(.freertos_data*)
    . = ALIGN(4);
    _freertos_data_end = .;
  } >HYPERRAM

Inside FreeRTOS.h file changed the to 1 

#ifndef configAPPLICATION_ALLOCATED_HEAP
	#define configAPPLICATION_ALLOCATED_HEAP 1
#endif

in main.c
created an array for ucHeap

/* USER CODE BEGIN PV */
uint8_t ucHeap[ configTOTAL_HEAP_SIZE ] __attribute__ ((section (".freertos_data")));
/* USER CODE END PV */

 Now downloaded the program using Debug
Error: Program gets HardFault Error even before going into main() function.

I think because i put a breakpoint in first line of main() function it is not reaching and i cannot 'reset` the debug using the reverse curved arrow.
What error is shown: 

vishnu_illikkal_0-1719985981744.pngvishnu_illikkal_1-1719986482100.png

vishnu_illikkal_2-1719987844486.pngheap_4.c having the problem

Observation/Guess : FreeRTOS functions are calling before the init of the External RAM or even before the program is fully start.
Some RWX permission warning also hapening i don't know what that is

vishnu_illikkal_3-1719988025394.png

If anyone knows this problem please replay. 
Thanks.

 

 

 

 

 

10 REPLIES 10
Pavel A.
Evangelist III

Yes, logically the SystemInit function is where the clocks and memories should be prepared. SystemInit is called before main() and all the C/C++ initializers. But this is not how the ST examples and Cube-generated projects actually are written. Maybe, because all the library code is in C, and it assumes the C initializers already run, and it all goes upside down... You need just to make a decision how/where the stuff should be initialized in your project.