Skip to main content
binarybee
Associate III
Sep 10, 2020 9:43 AM UTC
Solved

RAM function (code) placement using GNU GCC family

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.
Uwe Bonnes
Uwe BonnesBest answer
Chief
Sep 10, 2020 10:38 AM UTC

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

6 replies

Nikita91
Lead II
Sep 10, 2020 10:07 AM UTC

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
Sep 10, 2020 10:31 AM UTC

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
Sep 10, 2020 11:52 AM UTC

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

binarybee
binarybeeAuthor
Associate III
Sep 10, 2020 11:54 AM UTC

dont worry i checked these things, :)

Uwe Bonnes
Uwe BonnesBest answer
Chief
Sep 10, 2020 10:38 AM UTC

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
Sep 11, 2020 6:21 AM UTC

Thanks :)