execute code from internal ram

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

execute code from internal ram

1,423 Views
PEGE
Contributor I

Hello,

 

i'am working with a MCF5280.

 

I build my programm and flash it on controller.

 

Now i want to know, is it possipble to copy a function (für example MAIN) to the internal ram an execute it from this place ?

 

friendly regards Peter

Labels (1)
0 Kudos
13 Replies

882 Views
CrasyCat
Specialist III

Hello

 

Please search for FAQ-27860 on www.freescale.com.

 

This FAQ should explain how to achieve that.

 

CrasyCat

0 Kudos

882 Views
PEGE
Contributor I

Thanks a lot

0 Kudos

882 Views
PEGE
Contributor I

Okay now i copy the code from FAQ-27860. But it will not work.

 

I copied this code in the main.c und the Main-Function

 

#pragma define_section CopyToRAM "CopyToRAM " far_code__declspec (CopyToRAM) unsigned int Fibonacci(unsigned int n) {   for (int i = 0;i<100000;i++)      {            uart_putchar(0,0x3A);      }}

 further i did this code

.copyToRAM: AT(___DATA_ROM + SIZEOF(.data)){. = ALIGN (0x4);__START_COPYTORAM = .;*(CopyToRAM)__END_COPYTORAM = .;} >> userram

 into the .lcf for the external_flash

 

and moify the _romp part in this way

 

.romp : AT(_romp_at){__S_romp = _romp_at;WRITEW(___DATA_ROM); #ROM start addressWRITEW(___DATA_RAM); #RAM start addressWRITEW(SIZEOF(.data) + SIZEOF(.copyToRAM)); #sizeWRITEW(0);WRITEW(0);WRITEW(0);}

 now i dont know how to call the loop in the Fibonacci function.

 

does anyone know that problem ?

 

regards peter.

0 Kudos

882 Views
kef
Specialist I

Try removing extraneous space in pragma line. "CopyToRAM " to "CopyToRAM".

0 Kudos

882 Views
PEGE
Contributor I

Thanks but it make no difference.

 

i can call the function but when he try to enter the body it jumps into the exceptions.c

0 Kudos

882 Views
CrasyCat
Specialist III

Hello

 

What is the address displayed in the disassembly listing for the function Fibonacci?

What is the address of the function according to the map file?

 

CrasyCat

0 Kudos

882 Views
PEGE
Contributor I

Hello,

 

 the address displayed in the disassembly listing for the function Fibonacci is 0x00000000

 

its the SDRAM iam using a MCF5282 EVB

 

What is the address of the function according to the map file?

 

the adress in .elf.xmap is 0xFFE013A2

0 Kudos

882 Views
CrasyCat
Specialist III

Hello

 

I need the address of Fibonacci function in disassembly code inside of the debugger?

 

If you are using CodeWarrior V10.x there is a Disassembly view.

If you are using an earlier release, change the source pane in the Thread window to Mixed mode (instead of Source).

 

CrasyCat

0 Kudos

882 Views
PEGE
Contributor I

But 00000000 is displayed in the disassembly window.

 

this is where i call the function. (displayed in disassembly) 

 

jsr Fibonacci (0)              ; 0x00000000

 

regards peter

0 Kudos

882 Views
PEGE
Contributor I

now i get this warning.

 

Description    Resource    Path    Location    Type
_Fibonacci(CopyToRam) in file main_c.obj is referenced but has not been written. Check your linker command file.

0 Kudos

882 Views
CrasyCat
Specialist III

Hello

 

This one indicates that the section CopyToRam was not allocated anywhere in your lcf file.

 

So it looks like you have an issue with your linker file.

This also explains why you cannot jump to your function in RAM.

 

CrasyCat.

0 Kudos

882 Views
PEGE
Contributor I

I found the mistake.

 

its located in the linker file from faq-27860.

 

copyToRAM: AT(___DATA_ROM + SIZEOF(.data)){. = ALIGN (0x4);#Original from freescale#__START_COPYTORAM = .;
#change to
 __START_copyToRAM = .; *(CopyToRAM)#Original from freescale#__END_COPYTORAM = .;
#change to
 __END_copyToRAM = .;} >> userram

 so now it works !

 

thanks a lot for yout help

 

regards peter

0 Kudos

882 Views
Kerrie
Contributor I

Thanks this example helped me.

0 Kudos