Message Edited by CrasyCat on 2007-04-13 02:27 PM
Hello
To get code from some function copied to RAM and executed from there I would try the following:
1- Define the functions to be copied to RAM in a user defined section.
This is done as follows:
Code:
#pragma define_section RAMCode ".RAMCode" far_code__declspec(RAMCode) unsigned int Fibonacci(unsigned int n) { unsigned fib1, fib2, fibo; int i; fib1 = 0; fib2 = 1; fibo = n; i = 2; while (i <= n) { fibo = fib1 + fib2; fib1 = fib2; fib2 = fibo; i++; } return(fibo);}
2- In your .lcf file specify you want to place the user defined section into ROM.
Code:
.main_application_data : AT(___DATA_ROM) { . = ALIGN(0x8); *(.exception) . = ALIGN(0x8); __exception_table_start__ = .; EXCEPTION __exception_table_end__ = .; ___sinit__ = .; STATICINIT __START_DATA = .; *(.data) . = ALIGN(0x8); __END_DATA = .; __START_SDATA = .; *(.sdata) . = ALIGN(0x8); __END_SDATA = .; . = ALIGN(0x8); StartCopiedCode = .; *(.RAMCode) EndCopiedCode = .; } > DATA
3. Initialize a copy down block in the linker command file with information about data to be copied into RAM:
Code:
# Locate the ROM copy table into ROM after the initialized data _romp_at = CodeToCopy + SIZEOF(.CodeInRAM); .romp : AT(_romp_at) { __S_romp = _romp_at; WRITEW(___DATA_ROM); WRITEW(ADDR(.main_application_data)); WRITEW(SIZEOF(.main_application_data)); WRITEW(0); WRITEW(0); WRITEW(0); }
This should do it
CrasyCat
Hi Clarify Cat,
Could you please elaborate on where you put the code in step 2? Is this another section or another group?
What about "main_application_data" name? Is this the name of a Memory block ? Please clarify. Since I am using CW 5.9 for Power PC I was wondering if there would be any difference between this code and the code I need to run on my version of the compiler?
Thanks;
Hello
Wait a minute. If you are using Power PC, this does not apply to your case. This thread is for Coldfire project only.
In order to execute portion of your application from RAM in a PowerPC application, you need to create a ROM image of your application, and then copy this image into RAM
Attached document explains how to execute whole application from RAM.
If you need to run only selection portion of the application from RAM, make sure the code is stored in a user defined section and then place the user defined section into a GROUP that is allocated in RAM.
Sections .text and .rodata in this case will stay in ROM.
CrasyCat
Hello Crasy Cat,
In pursue of getting my code to run partially in RAM I have defined the appropriate sections and memory allocations. The final compilation generates the following error message,
[Link Error: Section ".sdata2" is overwriting the previous section address. So change the starting address of ".sdata2"]
I tried various combinations and nothing changed the error message. Please take a look at the attached .lcf file and let me know what you think is appropriate to be done.
Thanks;
Hello
Why did you place section .sdata2 in internal_flash.?
.sdata2 and .sbss2 should always be allocated next to one another.
So if you want to move sdata2 to flash you have to move there sbss2 as well.
Then the LOAD modified is only needed to placement of sections located in flash.
You do not need them on the section you place in internal_ram (.ivor_branch_table , .intc_hw_branch_table , .ivor_handlers ).
CrasyCat
Hi CrasyCat,
I appreciate your response, the modification you suggested is in place and I get an out of range error message in regards to pointers to my interrupt routine calls in hardware interrupts table! They are considered out of range eventhough the entire table is asked to be placed in RAM. I do not know how to redefine these labels to avoid these error message. I have 10 functions as such and there are 10 error message complaining that the labels in hardware interrupt table are out of range! Be the way, is there any tutorial or guidelines that specifies why these sections such as sbss or sdata2 and the like shall be placed in certain areas of memory? The .LCF and my HW branch table is attached for your verification.
Thanks;
Geek19
Hello
There seems to be an issue in your project.
I am unable to reproduce the trouble on a simple project.
I would recommend you to submit a service request for that.
Click here to submit a service request.
Make sure to attach a reproducible project and installed product information to the service request.
CrasyCat
_romp_at = ___DATA_ROM + SIZEOF(.main_application_data); .romp : AT(_romp_at) { __S_romp = _romp_at; WRITEW(___DATA_ROM); WRITEW(ADDR(.main_application_data)); WRITEW(SIZEOF(.main_application_data)); WRITEW(0); WRITEW(0); WRITEW(0); }
Hi There,
Does it matter where you place the .romp section? I've move mine to follow the initialised data section which places .romp before the .bss section now. It used to be after the .bss section and just before the end of stack.
Could you tell me also what .romp does and how it does it please. If this has already been answered on the forum please point me to the thread.
Thanks
Dave
Hello
I did never try to move the .romp section down in the linker file.
So I do not know whether this will work.
The data in the .romp section are processed by the function __copy_rom_sections_to_ram. This function is called from startup code and is implemented in
{Install}\MCU\ColdFire_Support\ewl\EWL_Runtime\Runtime_ColdFire\Source\ROMCopy.c
CrasyCat