ROM-RAM copying

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

ROM-RAM copying

3,251 Views
mickael
Contributor I
Hi everybody,
 
I am working with a coldfire MCF5235.
I have two questions concerning ROM-RAM copying :
 
1/ I am using the rom-ram copying with the lcf file. This works great. See below my linker file:
 
# Sample Linker Command File for CodeWarrior for ColdFire
MEMORY
{
 user   (RX)  : ORIGIN = 0x00000500, LENGTH = 0x0
 sdram  (RWX) : ORIGIN = 0x00000000, LENGTH = 0x0
 vector_ram (RWX) : ORIGIN = 0x00000000, LENGTH = 0x0
 sram  (RWX) : ORIGIN = 0x20000000, LENGTH = 0x0
 ext_sram (RWX) : ORIGIN = 0x30000000, LENGTH = 0x0
 ipsbar  (RWX) : ORIGIN = 0x40000000, LENGTH = 0x0
 ext_flash (RWX) : ORIGIN = 0xFF800000, LENGTH = 0x0
}
 
SECTIONS
{
 .sdram  : {} > sdram
 .vector_ram : {} > vector_ram
 .ipsbar  : {} > ipsbar
 .sram  : {
 
  . = ALIGN(0x10); #align next section on 16-byte boundary.
            *(.fec_data)
  . = ALIGN(0x10);
   
        } > sram    #places the section contents at the beginning of the
       #memory segment "sram"
 .ext_sram : {} > ext_sram
 
 .boot_flash :
 {
  vectors.s  (.text)
  mcf523x_lo.s (.text)
  hwinit.c  (.text)  
  C_4i_CF_StdABI_Runtime_Sodimas.a (.text)
  .= ALIGN(0x4);
 } > ext_flash
 
 __end_of_text = .;
                                                                                                      
 ___DATA_ROM  = __end_of_text;
  
 ___DATA_RAM  = ADDR(user);
 

 .sys_sram : AT(___DATA_ROM)
 {
  .= ALIGN(0x4);
   *(.text)
  *(.rodata)
  .= ALIGN(0x4);
  __START_DATA = .;
  *(.data)
  __END_DATA = .;
  __START_SDATA = .;
  *(.sdata)
  __END_SDATA = .;
  
  __SDA_BASE = .;
  .= ALIGN(0x4); 
 } > user

 
 .uninitialized_data :
 {
  __START_SBSS = .;
  *(.sbss)
  *(SCOMMON)
  __END_SBSS = .;
  __START_BSS = .;
  *(.bss)
  *(COMMON)
  __END_BSS = .; 
  . = ALIGN (0x4);
  ___HEAP_START = .;
  ___HEAP_END  = ___HEAP_START + 0x10000;
  ___SP_END  = ___HEAP_END;
  ___SP_INIT  = ___SP_END + 0x1000;
  .    = ALIGN(0x4);
 } >> user
 
 _romp_at = ___DATA_ROM + SIZEOF(.sys_sram);
 .romp : AT(_romp_at)
 {
  __S_romp = _romp_at;
  WRITEW(___DATA_ROM);
  WRITEW(ADDR(.sys_sram));
  WRITEW(SIZEOF(.sys_sram));
  WRITEW(0);
  WRITEW(0);
  WRITEW(0);
 }
 
 ___IPSBAR  = ADDR(.ipsbar);
 ___VECTOR_RAM  = ADDR(.vector_ram);
 ___SDRAM  = ADDR(.sdram);
 ___SDRAM_SIZE  = 0x01000000;
 ___SRAM   = ADDR(.sram);
 ___SRAM_SIZE  = 0x00010000;
 ___EXT_SRAM  = ADDR(.ext_sram);
 ___EXT_SRAM_SIZE = 0x00080000;
 ___EXT_FLASH  = ADDR(.boot_flash);
 ___EXT_FLASH_SIZE = 0x00800000;
 ___heap_addr   = ___HEAP_START;
 ___heap_size   = 0x10000;
 __SP_INIT   = ___SP_INIT; 
 
}
 
 
 
My question is to know when is done the copy of the section "user" from ram to rom. Is it done after the execution of the section boot flash?
 
 
2/ My second question is to know if it is possible to have a conditionnal ROM RAM copying.
 I would like to specify in the lcf file wether I copy  to ramone flash zone or another.
 
Typically :
 
if (flag)
copy the flash zone A to RAM
else
copy the flash zone B to RAM
 
  
Thanks
 
 
 
Labels (1)
0 Kudos
4 Replies

389 Views
CrasyCat
Specialist III
Hello
 
1- The copy of the data from ROM to RAM is performed by the startup code.
    Basically the startup code is doing the following:
       - Disable interrupts 
       - Initialize stack pointer and diverse registers
       - Initialize hardware
       - Initialize section bss & sbss to 0
       - Copy data from ROM to RAM
       - call main
 
    You can look at the code of the startup function in
       {Install}\E68K_Support\Runtime\Runtime_68K\Runtime_ColdFire\(Source)\E68k_startup.c
 
2- There is no way to add conditional code in the linker control file.
     The linker file syntax does not provide support for conditional blocks.
 
CrasyCat
0 Kudos

390 Views
mickael
Contributor I
Thank you for your quick answer crazy cat! But I still don't catch everything!
 
1/ I thought the startup code was in mcf523x_lo.s, see below :
 
/********************************************************************
 * This is the main entry point upon hard reset.
 */
asm_startmeup:
_asm_startmeup:
 
 move.w #0x2700,sr
 /* Initialize IPSBAR */
 move.l #(___IPSBAR + 1),d0
 move.l d0,0x40000000
 
 /* Initialize RAMBAR1: locate SRAM and validate it */
 move.l #(___SRAM + 0x21),d0
    .long   0x4e7b0C05      /* movec d0,RAMBAR1 */
 /* Point Stack Pointer into SRAM temporarily */
 move.l #(___SRAM + 0x10000),sp
 /* Initialize mcf523x periphs, etc */
 jsr  mcf523x_init
 /* Relocate Stack Pointer */
 move.l #___SP_INIT,sp
 /* Jump to the main process */
 /* jmp  _main */
  jmp     start
 
 bra  .
 nop
 nop
/* halt */
 
What is executed first? mcf523x_lo.s or E68k_startup.c?
 
 
2/ So for you, if I want to do my conditionnal ROM-RAM copying, I have to modify E68k_startup.c and recompile it.
 
Thanks again
 
0 Kudos

390 Views
Arev
Contributor III
Hello,

"asm_startmeup" is executed first and "jmp start" jump to E68k_startup code.
 
I think you have to define different lcf file and target for each configuration you want.
 
I Hope this helps..

Bye
 
<< Freescale MCF5234/35 with CodeWarrior 6.2 >>
0 Kudos

390 Views
mickael
Contributor I

1/ Thank you Arev for you help on boot sequence.

 

2/ Defining several  lcf and several targets is useless for me. I ‘am in the following configuration :

 

FLASH MEMORY :

Boot zone

Zone A

Zone B

 

I want to boot on the boot zone and then (considering a flag in the flash) either copy to RAM zone A or zone B. Then I want to boot in RAM.

 

Thanks

0 Kudos