Hi all,
Is there any way to jump some flash locations inside a code. eg:
Starting location of flash
0x00000050 int main() 0x00000054 { 0x00000058 printf("Hai"); 0x0000005C Jumpt to flash address for 2nd printf 0x00075000 printf("Bye") ------------ }
How to implement this type of Flash location jumping in Keil compiler.Is it possible to jump?? Kindly reply...
In reality, you are trying to solve an invalid problem.
You can have the linker place a function at a specific memory address. But that function will be part of your program so the program will just be fragmented. That is why the linker configuration file is called a scatter file.
But your example program is not applicable for a real program spreading downloadable modules to different regions of the code memory. You just have too huge issues with implementing it for real since the compiler/linker will make use of runtime library functions, global variables etc that will move around for different builds.
If you do want bootloader + application then read up on that. But that is completely different from what you outline above. The concept of callable functions (note the difference between jump and call...) works best when the functions are written in assembler, giving you 100% control of the assumptions each function makes.
I thionk this is the old nugget "sharing routines between boot and app"
there is only one answer: DONT
Erik
As I did write in previous post: Sharing routines normally requires assembler code to make sure that the developer don't have to suffer from unknown global variables or helper library functions that are linked at different locations in the different builds.
Sharing routines can work. But it so very often fails badly. When it works, it wasn't developed by someone who starts the project by asking on a forum how to do it.
Just such a thing as printf("hello world"). printf() sounds like one function. But it has a large backend of helper functions. And depending on implementation, it may not be fully reentrant but may have global state variables that must be stored at a specific address.
And why have a printf("hello world") stored at a specific location when it's enough to just store the string "hello world"?
Sharing routines can work. But it so very often fails badly
an assumed situation:
someone ask me "to save memory, can we share routines between boot and app"
with decades of experience, my answer will be: "sure, but first you must sign this document stating that I am not responsible for whatever ill effects that may pop up resulting from this"