cancel
Showing results for 
Search instead for 
Did you mean: 

Executing Code from XRAM2

achim2
Associate II
Posted on October 11, 2007 at 15:44

Executing Code from XRAM2

6 REPLIES 6
achim2
Associate II
Posted on September 25, 2007 at 15:33

Hello all,

in order to flash an application into IFLASH and XFLASH (ST10F276), I am copying some code (lets call it the bootstrapper) from flash into XRAM2, which includes flash and communication routines.

The basic steps are:

1.) stop all IRQs in normal application

2.) copy bootstrapper to XRAM2

3.) make a JMPS to the RAM location, run there and do the comm/flash stuff

Everything goes right when i do this on a HITEX debugger, but when I do it on real hardware, it fails.

I am using the large memory model.

Before executing the big while loop in the bootstrapper, the DPPs are initialized, also user and system stack.

XPERCON, SYSCON and so on remain untouched. Before jumping to the bootstrapper, XRAM1 and XRAM2 are both accessible.

I know that on the debugger the bootstrap code does not run out of the real XRAM2, but out of simulation SRAM.

Is there something special to pay attention to when running code out of XRAM2? Are my basic steps above erroneous?

Kind regards

Achim

najoua
Associate II
Posted on September 26, 2007 at 06:03

Hello Achim,

Could you please tell me:

- what is the XRAM2 address you are acceeding?

- what is the DPPs values?

- what is the XPERCON register value?

- what is the SYSCON register value?

- in which order the SYSCON and XPERCON registers are configured i.e. SYSCON is configured before or after XPERCON?

Waiting for your feedback,

Kind regards,

Najoua.

achim2
Associate II
Posted on September 26, 2007 at 07:58

Hello Najoua,

thanks for your fast reply.

- The XRAM2 adress is 0x0F0000 (beginning of XRAM2 on the F276)

- The DDP values are:

MOV DPP0, #PAG ?BASE_DPP0

MOV DPP1, #PAG ?BASE_DPP1

MOV DPP2, #PAG ?BASE_DPP2

MOV DPP3, #PAG ?BASE_DPP3

- The XPERCON and SYSCON registers are not written when I jump to the bootstrapper, but I cannot say yet which values they actually have, as I have to implement some debug code to read out these values.

As everything works fine (IRAM,XRAM1/2,IFLASH,XFLASH...) before jumping to the bootstrapper, i dont think I have to reinitialize the XPERCON and SYSCON, as they were correctly initialized on the normal startup.

Regards

Achim

najoua
Associate II
Posted on September 28, 2007 at 06:32

Hello karlnapf2000,

The XRAM2 is located at 0xF0000 so you must be sure a DPP pointer is referring to this area i.e one DPP must be set to 15 (0Fh).

Regards,

Najoua.

michaelgaus9
Associate II
Posted on October 02, 2007 at 08:53

Are the flash programming routines located in the XRAM2 address range (starting at 0xF0000) by the linker? If not, it only works, if your code is relocatable. If you have big loops for example, there are absolute jumps inserted by the compiler which jump to the wrong address when executed in XRAM2.

achim2
Associate II
Posted on October 11, 2007 at 15:44

Dear readers,

the problem is solved meanwhile. It was a wrong assignment of DPPs.

In the large memory model (Tasking Compiler) i had to do the following:

#pragma asm

MOV STKOV, #?SYSSTACK_BOTTOM ; Set stack underflow pointer.

MOV STKUN, #?SYSSTACK_TOP ; Set stack overflow pointer.

MOV SP, #?SYSSTACK_TOP ; Set stack pointer.

MOV DPP0, #0 ; restore DPP0 to its default value

MOV DPP1, #PAG (?USRSTACK_TOP - 2) ; set DPP1 to page of user stack

MOV DPP2, #PAG C166_DGROUP ; set DPP2 to page of default data

MOV DPP3, #03h ; Set data page pointer to page 3 (SFR)

MOV R0, #POF ?USRSTACK_TOP ; set user stack pointer

BSET R0.0EH ;

#pragma endasm

Like this, i have access to the default data group, were most of the variables are located.

In on of my previous postings the DPPs were initialized with their base values, which of course had to fail.

Thanks for your answers!

Regards

Achim