ROM-RAM copying - placing function/file in RAM

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

ROM-RAM copying - placing function/file in RAM

1,890 Views
mike_pcs
Contributor II
I've searched the forums and know that this has been covered before, but I can't quite find the answer I'm looking for or get the linker to behave the way I'd like. 
 
I want to place a function or file in RAM using the linker file.  The basic structure of the file is like the one in the Build Tools manual:
 
 

# ROM location: address 0x0
# RAM location: address 0x800000
# For clarity, no alignment directives in this listing

MEMORY {
TEXT (RX) : ORIGIN = 0x0, LENGTH = 0
DATA (RW) : ORIGIN = 0x800000, LENGTH = 0
}

SECTIONS{
.main :
{
   *(.text)
   *(.rodata)
} > TEXT

# Locate initialized data in ROM area at end of .main.
.main_data : AT( ADDR(.main) + SIZEOF(.main) )
{
   *(.data)
   *(.sdata)
   *(.sbss)
} > DATA

.uninitialized_data:
{
   *(SCOMMON)
   *(.bss)
   *(COMMON)
} >> DATA

 

I want to put the file/function in the main_data section, but since it's already included in the TEXT section (with the *(.text) directive) the linker doesn't include it again.  I don't want to explictly list out every file in the TEXT section becuase there are a lot and it's more difficult to maintain.  Is there a way to exclude a file/function from that section?

 

I read something in the manual about creating a named file group, but couldn't see how this was done (there were no examples that I could find).

 

If anyone's had any luck with this in the past or can suggest a better way, I'd be grateful.

Mike

Labels (1)
0 Kudos
3 Replies

421 Views
CrasyCat
Specialist III
Hello
 
Are you building code for ColdFire or Power Architecture?
 
Basically you need to place all the functions you want to copy to RAM in a user defined section and then place the section in RAM in the linker file.
 
Syntax depends on the target processor, so can you indicate:
- Which CPU are you targeting (HC08, HC12, Coldfire, ..)
- Which version of CodeWarrior are you using?
  To retrieve that info:
   - Start CodeWarrior
   - Select Help -> About Freescale CodeWarrior
   - Click on "Install Products"
   - CodeWarrior version used is displayed on top in the Installed Products dialog.
 
CarsyCat
0 Kudos

421 Views
mike_pcs
Contributor II
Coldfire, Codewarrior 5.9
 
I realiize that I need to put the files in a separate section and then put that section in RAM.  From the linker example file above, there is a RAM section for initializtion data that can be used for this purpose.  However, all the code needs to come before this in the map (the ROM location for the data to be initialized is placed after the code).  I'd like to leave the one function/file out of the text section above, and place it into the data section.  I don't understand how I can specify that file after using the * command to include all the other code segments for the text area.  Maybe it can't be done?
0 Kudos

421 Views
mike_pcs
Contributor II
I think that I have it working now,  I found your answer to a previous thread here that sorted me out.  I would suggest a documentation update of the Build Tools reference manual to inlcude the information on creating a user defined section for this purpose (I know that info is in the docs, but it would be useful to have it in the ROM-RAM copying section).
 
Thanks!
0 Kudos