Skip to main content
binarybee
Associate III
September 10, 2020
Solved

RAM function (code) placement using GNU GCC family

  • September 10, 2020
  • 3 replies
  • 2795 views

Hi guys,

I would like to ask how properly place the function (code). I have solved the ld. script (have already the section in ram for code there) and functions which I want to place in ram has section attributes, but I read that the long call attribute is also necesarry and –mlong-calls compiler flag has to be set. I did every single step but I'm getting wdg interrupt everytime I want execute function from RAM.

(The clocks are also enabled for RAM)

Maybe I missed some stupid thing there.

Thanks in advance for any advice.

This topic has been closed for replies.
Best answer by Uwe Bonnes

I have used functions in RAM on CortexM without -mlong-call. GCC has the concept of ***_venneer https://stackoverflow.com/questions/56019518/linker-script-gcc-how-to-avoid-veneer-call

3 replies

Nikita91
Lead II
September 10, 2020

What MCU ?

What RAM address ?

Do you see the right address in the map file ?

Where do you see the –mlong-calls compiler flag has to be set ?

binarybee
binarybeeAuthor
Associate III
September 10, 2020

https://gcc.gnu.org/onlinedocs/gcc-4.1.2/gcc/ARM-Options.html

"Tells the compiler to perform function calls by first loading the address of the function into a register and then performing a subroutine call on this register. This switch is needed if the target function will lie outside of the 64 megabyte addressing range of the offset based version of subroutine call instruction."

Map file has correct address and I would say what is more important that function is really copied in SRAM, which I checked with debugger. :smirking_face:

MCU and RAM addresses are probably irelevant, after it is copied in SRAM and the correctness of copied data is checked, the problem has to be somewhere else.

Nikita91
Lead II
September 10, 2020

I am asking for the MCU and RAM address because not all MCUs allow code in all RAMs ...

binarybee
binarybeeAuthor
Associate III
September 10, 2020

dont worry i checked these things, :)

Uwe Bonnes
Uwe BonnesBest answer
Chief
September 10, 2020

I have used functions in RAM on CortexM without -mlong-call. GCC has the concept of ***_venneer https://stackoverflow.com/questions/56019518/linker-script-gcc-how-to-avoid-veneer-call

binarybee
binarybeeAuthor
Associate III
September 11, 2020

Thanks :)