This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Execute program in absolute address

Hi,

If I want compiler my project at specified locate, the only thing tat I need to do is following image?  Is it right?

 

After I program this program into address 0x0001D000 of flash memory, If I want use other program (which locate at address 0x00000000) to execute above program, who can I do?

Thank you,

Chianglin

  • Yes, you are right. By setting the iROM1 start address, the linker will generate the hex file with the absolute address to start at the address you configured. 

    If you want to make a program that run at 0x0000000 (I assume you don't use a softdevice) and switch to another program in different place in flash you are creating a bootloader. 

    We have a bootloader without softdevice example here.

    It's from a very old post but the principle should be the same. You forward the vector table and then you jump the pc to the reset handler of the new application. 

  • Hi Hung Bui,

    I had write a simple program which only blink a LED light, please find following attach file

    blinkyTest.7z

    It can work correctly because the program is locate from 0x00000000, please find follwing image

    If I locate program at 0x1000, the program will now work (Note: I had erase all the flash when I had erase all of the flash memory). please find following image.

    Thank you,

    Chianglin

  • I'm not sure I understand what you want to do ?

    Why do you want to locate your application at 0x1000 when leaving address 0x0000000 empty ? It won't work because the reset handler on Cortex M4 is hardcoded at 0x000000. 

    You need to have a program (or at least reset handler) at 0x000000 to jump to your application. That's why I suggested the bootloader. 

  • Hi Hung Bui,

    Sorry, the structure of bootloader is too complex for me.

    Actually, I only want to do two jobs:

    1. Put a function on the specified address (For example: put a function to address 0x10000).

    2. Execute this function from other function. How can I execute this function my "Jump command" (For example: change "program counter" to 0x10000).

    Would you please tell me how can I do these two job?

    Thank you,

    Chianglin

  • and why do you want to put a function at a specific address? It's a pretty unusual thing to want to do, in fact there's almost never a reason for it. You can do it with attributes on the function or a special linker map which forces the function into a section you define at one place and then you'd just call it and it would just work. However .. it really feels like you're trying to solve a different problem here. 

    You can google for how to put a function at a specific address, it depends on the compiler you're using. eg here's how Keil does it

Related