cancel
Showing results for 
Search instead for 
Did you mean: 

RAM function (code) placement using GNU GCC family

binarybee
Associate III

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.

1 ACCEPTED SOLUTION

Accepted Solutions
Uwe Bonnes
Principal III

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

View solution in original post

6 REPLIES 6
Nikita91
Lead II

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
Associate III

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.

Uwe Bonnes
Principal III

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

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

dont worry i checked these things, :)

Thanks :)