Skip to main content
jiangpen
Associate III
October 29, 2021
Question

Run code from ram of STM32H7

  • October 29, 2021
  • 2 replies
  • 2696 views

I have a customized bootloader app which needs to update itself.

I think if linking all the code to RAM and run code in RAM, then it should able to update itself as it does not require accessing flash.

my thought is changing all section with flash (>FLASH) to RAM (>RAM AT> FLASH), ideally it should work.

But it does not, system even not run at all, and cannot set break point.

may I know if this strategy works and may I know how to put entire program into ram and run?

if there is an example, then that will be great.

thanks

This topic has been closed for replies.

2 replies

thundertronics.com
Visitor II
October 29, 2021

Update 2022: after recent HAL update also must uncomment

#define USER_VECT_TAB_ADDRESS

in Core/Src/system_stm32xxx.c

see Run code from RAM on STM32H7 (thundertronics.com) for details.

I have developed a custom bootloader that works both from FLASH and RAM of STM32H7. What you need is:

  1. Go to Project → Properties → C/C++ Build → Settings → Tool Settings tab → MCU GCC Linker
  2. Set Linker Script to ${workspace_loc:/${ProjName}/STM32H750VBTX_RAM.ld}
  3. Go to Project → Properties → C/C++ General → Paths and Symbols → Symbols tab
  4. Add symbol VECT_TAB_SRAM
  5. Then you can run your program through Debug.

Make sure you arrange memory regions right if you use DMA. Google on VECT_TAB_SRAM to get more related information.

0693W00000GVrlQQAT.png0693W00000GVrlkQAD.png 

Pavel A.
October 29, 2021

Even if your app runs from RAM you need to put it on the flash.

The bootloader (running off the flash) will copy it into RAM and jump to it.

Then the app can rewrite its copy in the flash.