We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
Hello. I want to relocate some function’s from Flash to a different position in PSRAM for a bootloader.
The problem is: Keil generates absolute jumps in the original function. With relative jumps whould it work.
I have copied the original functions to the RAM like this: ------------ Flash function a at 0xC01000 ------------ Flash function b at 0xC02000 ------------ Flash function c at 0xC02800 ->(to copy in RAM at 0xE00000) ------------
Now I copy the c-function from 0xC02800 to RAM at 0xE00000.
The Problem: In the function c is a IF cause, that jumps to the end of the function at 0xC02872:
JMPA cc_UC, 0xC02872 ( +72 Bytes)
If i execute this copied function at the new position (E00000), the jump is located to E02872
JMPA cc_UC, 0xE02872 ( + 2872 Bytes)
and not to 0xE00072 ( + 72 Bytes).
Is there a compiler switch to generate relative jumps (JMPR, CALLR) instead to absolute Jumps (JMPA+,JMPA-,CALLA)?
Or is there a other solution for this problem?
(I need to use the HCompact model, to access all functions and the whole address-space for variables.)
Thanks
That means: i have to inspect the Code in RAM and search for 0xCA ( CALLA xxxx ) to patch the following adress.
No. It means you have to stop what you're doing and reconsider how you got there. If the compiler won't generate position-independent code, then you can't assume you can use position-independent code unless you're prepared to write it yourself --- in assembler.
Instead, you can compile (and link) your code for its actual run-time location, but tell the linker to store it elsewhere in the image. Then you copy it to its target location before you run it. I'll assume Keil's C16x linkers have support for that.