Skip to main content
lshan.1
Associate
September 30, 2020
Solved

I want the code is copied from Flash to RAM after poweron,then the code is running at RAM.

  • September 30, 2020
  • 2 replies
  • 2568 views

I've changed the .ld file for STM32G474 generated by STM32CUBEIDE.

The part of old .ld file is like this,

0693W000004ICyeQAG.jpg

I added ">RAM AT" at the last line like this,

0693W000004ICx8QAG.jpg

But when I'm debugging,the code is running into the HardFault Handler.I want to know if something else need to be edited.

This topic has been closed for replies.
Best answer by Tesla DeLorean

Need to ​make sure linker places things as expected.

Code in startup.s needs to facilitate moving the code.

Hard Faults typically provide enough information to understand/fix the issue. Likely the data hasn't been​ moved prior to jumping into it.

2 replies

Tesla DeLorean
Tesla DeLoreanBest answer
Guru
September 30, 2020

Need to ​make sure linker places things as expected.

Code in startup.s needs to facilitate moving the code.

Hard Faults typically provide enough information to understand/fix the issue. Likely the data hasn't been​ moved prior to jumping into it.

Tips, Buy me a coffee, or three.. PayPal VenmoUp vote any posts that you find helpful, it shows what's working..
lshan.1
lshan.1Author
Associate
September 30, 2020

Thanks for your help.

I don't know if you could give me some advice about modifying the code in startup.s. By using the Disassembly,the reason of Hard Faults was that the code was at the last address of RAM.Then I didn't know what to do.Maybe I need learn more about the boot process of ARM and debug method. I also tried to use __attribute__ and memcpy (code is copied from flash to RAM ) to realize it,but it also didn't work.Hope you can reply when free.I will also try to find a way to move the code correctly.

NOzho.1
Visitor II
September 9, 2021

Hey! Did you manage to solve the problem?