dangerous relocation: l32r: literal placed after use

brebisson
Posts: 31
Joined: Fri Dec 22, 2023 9:44 am

dangerous relocation: l32r: literal placed after use

Postby brebisson » Tue Jan 21, 2025 11:14 am

Hello,

The following 3 lines in my code generate the following error (esp-idf esp32-C3 in visual studio code)
"dangerous relocation: l32r: literal placed after use"

These lines are in the same function, but at different locations....

I think that I have a clue as to what might be happening for the 2 bottom ones, but the first one is less obvious.
Even less obvious is how to fix it!

Can anyone help me?
Thanks,
Cyrille

Code: Select all

        uint32_t newDeltaBetweenSteps= 1000000 / (Abs(currentSpd));
        *((uint32_t*)GPIO_OUT_W1TS_REG)=1<<stp; stpVal= 1;
        *((uint32_t*)GPIO_OUT_W1TC_REG)=1<<stp; stpVal= 0;

MicroController
Posts: 1954
Joined: Mon Oct 17, 2022 7:38 pm
Location: Europe, Germany

Re: dangerous relocation: l32r: literal placed after use

Postby MicroController » Tue Jan 21, 2025 12:39 pm

Is that code in an IRAM function?

Potentially helpful information, albeit not a full solution: https://stackoverflow.com/questions/195 ... error-mean

brebisson
Posts: 31
Joined: Fri Dec 22, 2023 9:44 am

Re: dangerous relocation: l32r: literal placed after use

Postby brebisson » Tue Jan 21, 2025 1:04 pm

Hello,

Yes, it is an IRAM_ATTR function.

I tried adding: idf_build_set_property(COMPILE_OPTIONS "-mtext-section-literals" APPEND)
in mymakefile, But it did not work...


It first seemed to work.. But then it did not compile on 2nd test!

No clue why:-(

Cyrille

MicroController
Posts: 1954
Joined: Mon Oct 17, 2022 7:38 pm
Location: Europe, Germany

Re: dangerous relocation: l32r: literal placed after use

Postby MicroController » Tue Jan 21, 2025 4:02 pm

https://docs.espressif.com/projects/esp ... de-in-iram
constants inside an IRAM_ATTR function may not be placed in RAM automatically. It is possible to use DRAM_ATTR attributes to mark these, or using the linker script method will cause these to be automatically placed correctly.

Who is online

Users browsing this forum: No registered users and 111 guests