Jump to content

How Do You Force A Function To A Specific Address In Flash?


Recommended Posts

Hi All

 

Well, I thought Id open up my last question in a hope that I get even more help.

 

If I have a function

 

void

foobar()

{

nop();

}

 

For example, how do I force it to be at FLASH ROM address 0x8000?

 

Im thinking of the asm org 0x8000 command but in BoostC++. Can this be done? Is it a linker thing?

 

I need to put a function in a safe block of FLASH so it is NOT erased as I do an on the fly re-program of the firmware.

 

All thoughts welcome

 

 

Neil

Link to post
Share on other sites

Hi Neil,

 

Here is something to think about.

#include <system.h>

void MyFunc(void);

void main()
{
MyFunc();
}

void MyFunc(void)
{
char mychar;

mychar = 0;
}

 

In the linker option, set -rb 0x7ffc to get the assembler code looking like this:-

#include <system.h>

void MyFunc(void);

void main()

{
MyFunc();
8004  EC00F040	  CALL MyFunc_00000

}
8008  0012		  RETURN


void MyFunc(void)

{
char mychar;

mychar = 0;
8000  6A01		  CLRF MyFunc_00000_1_mychar

}
8002  0012		  RETURN

}
////////////////////////////////////////
// Code with no source :-)
////////////////////////////////////////
7FFC  EF05F040	  GOTO	_startup

800A			_startup
800A  EF02F040	  GOTO	main

 

There will be a few surplus instructions but your function should if your lucky start at address 0x8000.

 

Its worth a try as a last resort.

 

Cheers

 

Reynard

Link to post
Share on other sites
  • 11 months later...

Join the conversation

You are posting as a guest. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...