How to jump from Bootloader to MainApplication?

In the project I’m working on, I’m loading two separate applications

to the AT91SAM256 Flash, the first one is the Bootloader and the

2nd is the Main Application.

For the Bootloader, I have finished the receiving bin file, decripting it to hex buffer and writing the hex buffer to flash. The next step is to jump to the main application.

I write the code like this(not working):

(defined and declared at the beginning)

typedef void (*tFuncP)();

(In Main() function…)

tFuncP pFunction;

pFunction = (tFuncP)(APPLICATION_ADDRESS);

(*pFunction)();

Is there any thing wrong with the jump_to_main code?

The compiler i use is Keil uVision 3.23.

Hope somebody can help me…

Thanks in advance!

Only tested with gcc, but will give you an idea:

#define FLASHSTART 0x40002010

typedef void (*USERMAIN)(void);

static USERMAIN pUserApp = (USERMAIN)FLASHSTART;

then to call function:

pUserApp();

Regards

Spen