cancel
Showing results for 
Search instead for 
Did you mean: 

Running code in RAM on STM32H7

ADion
Associate

Hi,

I have to to run my code in RAM on STM32H7 and debug it.

I put my code in RAM_D1 (start address = 0x24000004) changing the linker file in this way:

 /* The program code and other data goes into FLASH */

 _sl_my_Code = LOADADDR(.my_Code); /* pnt to the flash */

 .my_Code :

 {

  . = ALIGN(4);

  _smy_Code = .; /* define a global symbols at start of code */

    *(.my_Code)

    *(.my_Code*)

  . = ALIGN(4);

  _emy_Code = .;    /* define a global symbols at end of code */

 } > RAM_D1 /* code execute in ram */

.my_Code is the code that I wish to run in RAM.

The debug does not work and the code execution goes in Error Handler status.

2 REPLIES 2
Khouloud GARSI
Lead II

Hello @ADion​ ,

Could you please check whether your vector table is relocated into internal SRAM. This is done by uncommenting "/* #define VECT_TAB_SRAM */" in "system_stm32h7xx.c" file.

Khouloud.

Just changing the Linker Script is not sufficient to get data into RAM, you need to add code in startup.s to unpack this code/data from FLASH and into RAM.

Some H7 RAMs require clocks to be enabled too. GNU/GCC does a really poor job of managing load regions and unpacking automatically.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..