cancel
Showing results for 
Search instead for 
Did you mean: 

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

lshan.1
Associate II

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.

1 ACCEPTED SOLUTION

Accepted Solutions

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 Venmo
Up vote any posts that you find helpful, it shows what's working..

View solution in original post

3 REPLIES 3

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 Venmo
Up vote any posts that you find helpful, it shows what's working..

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
Associate

Hey! Did you manage to solve the problem?