Copy ROM to RAM Coldfire .lcf-File

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 

Copy ROM to RAM Coldfire .lcf-File

6,436 次查看
Conair0001
Contributor I
Hello,
 
I'm currently running software from Internal RAM in MCF54455.
Running from FLASH directly is too slow.
 
Can anybody help me to change my lcf-file?
Is there anything else I have to do, that it gets copied from FLASH to RAM and executed from RAM?
 
 
This is my LCF-FIle:

KEEP_SECTION { .vectortable }
MEMORY {
  interrupts  (RX) : ORIGIN = 0x80000000, LENGTH = 0x00000600
  code        (RX) : ORIGIN = 0x80000600, LENGTH = 0x00005154
  data        (RW) : ORIGIN = 0x80005754, LENGTH = 0x000028AC
}
SECTIONS {
  .interrupts :
  {
    ___VECTOR_RAM = .;
    * (.vectortable)
    . = ALIGN (0x4);
  } > interrupts
  .text :
  {
    * (.text)
    . = ALIGN(0x4);
    * (.rodata)
    . = ALIGN(0x4);
    ___ROM_AT = .;
    ___DATA_ROM = .;
  } > code
  .data : AT(___ROM_AT)
  {
    ___PLL_CODE_START =.;
    * (.changePllCode)
    . = ALIGN(0x4);
    ___PLL_CODE_END =.;
    ___PLL_CODE_SIZE = ___PLL_CODE_END - ___PLL_CODE_START;
    ___DATA_RAM = .;
    * (.exception)
    . = ALIGN(0x4);
    __exception_table_start__ = .;
    EXCEPTION
    __exception_table_end__   = .;
    ___sinit__ = .;
      STATICINIT
    ___DATA_START =.;
    * (.data)
    . = ALIGN (0x4);
    ___DATA_END   =.;
    __SDATA_START =.;
    * (.sdata)
    . = ALIGN (0x4);
    __SDATA_END = .;
    __SDA_BASE = .;
    . = ALIGN(0x4);
  } > data
  .bss :
  {
    __START_SBSS = .;
    * (.sbss)
    *(SCOMMON)
    __END_SBSS = .;
    __START_BSS = .;
    * (.bss)
    * (COMMON)
    __END_BSS = .;
    . = ALIGN(0x4);
  } >> data
  # Heap and Stack sizes definition
  ___heap_size = 0x400;
  ___stack_size = 0x400;
  # 32 Kbytes Internal SRAM
  ___RAMBAR = 0x80000000;
  ___RAMBAR_SIZE = 0x00008000;
  ___SP_AFTER_RESET = ___RAMBAR + ___RAMBAR_SIZE - 4;
  ___SP_SIZE = 0x0400;
  ___HEAP_START = .;
  ___HEAP_END = ___HEAP_START + ___heap_size;
  ___SP_END = ___HEAP_END;
  ___SP_INIT = ___SP_END + ___stack_size;
  ___heap_addr = ___HEAP_START;
  ___heap_size = ___HEAP_END -  ___HEAP_START;
  __SP_INIT = ___SP_INIT;
  _romp_at = ___ROM_AT + SIZEOF(.data);
  .romp : AT(_romp_at)
  {
    __S_romp = _romp_at;
    WRITEW(___ROM_AT);
    WRITEW(ADDR(.data));
    WRITEW(SIZEOF(.data));
    WRITEW(0);
    WRITEW(0);
    WRITEW(0);
  }
}
 
Thanks and best regards,
Konrad.
标签 (1)
标记 (1)
0 项奖励
回复
6 回复数

1,941 次查看
Conair0001
Contributor I
by the way I'm using CodeWarrior 5.9.0 build 2502
 
I put my software into a EXTERNAL FLASH project.
Then I selected for the memory locations in Processor Expert INTERNAL RAM if I just start the program it runs fine.
 
However if I try to upload it with the FLASHTOOL it says that the data I want to FLASH is out of FLASH area.
 
Now I modified the .lcf-File so that everything is placed into FLASH and placed the copy table at the end of the .lcf-file like I found in Targeting Coldfire document.
(Does anybody know another/additional documentation that shows how to copy from FLASH to RAM)
 
With my modifications the FLASHTOOL doesn't complain anymore, but the program doesn't run.
If I press debug after flashing it stops at location 0x0 with 0xbababababa inside.
 
This is my .lcf-file:
 
 
## ###################################################################
##
##     THIS BEAN MODULE IS GENERATED BY THE TOOL. DO NOT MODIFY IT.
##
##     Filename  : EXTERNAL_FLASH.lcf
##
##     Project   : Project
##
##     Processor : MCF54455VR266
##
##     Compiler  : CodeWarrior MCF C Compiler
##
##     Date/Time : 24/07/2008, 11:50
##
##     Abstract  :
##
##     This file is used by the linker. It describes files to be linked,
##     memory ranges, stack size, etc. For detailed description about linker
##     command files see CodeWarrior documentation. This file is generated by default.
##     You can switch off generation by setting the property "Generate linker file = no"
##     in the "Build options" tab of the CPU bean and then modify this file as needed.
##
##     (c) Copyright UNIS, spol. s r.o. 1997-2007
##
##     UNIS, spol. s r.o.
##     Jundrovska 33
##     624 00 Brno
##     Czech Republic
##
##     http      : www.processorexpert.com
##     mail      : info@processorexpert.com
##
## ###################################################################
KEEP_SECTION { .vectortable }
MEMORY {
  interrupts  (RX) : ORIGIN = 0x80000000, LENGTH = 0x00000300
  code        (RX) : ORIGIN = 0x80000300, LENGTH = 0x00005354
  data        (RW) : ORIGIN = 0x80005654, LENGTH = 0x000029AC
}
SECTIONS {
  .interrupts :AT (0x04000000)
  {
    ___VECTOR_RAM = .;
    * (.vectortable)
    . = ALIGN (0x4);
  } > interrupts
  .text :AT (0x04000000 + SIZEOF(.interrupts))
  {
    * (.text)
    . = ALIGN(0x4);
    * (.rodata)
    . = ALIGN(0x4);
    ___ROM_AT = .;
    ___DATA_ROM = .;
  } > code
  .data :  AT (0x04000000 + SIZEOF(.interrupts) + SIZEOF(.text))    #AT(___ROM_AT)
  {
    ___PLL_CODE_START =.;
    * (.changePllCode)
    . = ALIGN(0x4);
    ___PLL_CODE_END =.;
    ___PLL_CODE_SIZE = ___PLL_CODE_END - ___PLL_CODE_START;
    ___DATA_RAM = .;
    * (.exception)
    . = ALIGN(0x4);
    __exception_table_start__ = .;
    EXCEPTION
    __exception_table_end__   = .;
    ___sinit__ = .;
      STATICINIT
    ___DATA_START =.;
    * (.data)
    . = ALIGN (0x4);
    ___DATA_END   =.;
    __SDATA_START =.;
    * (.sdata)
    . = ALIGN (0x4);
    __SDATA_END = .;
    __SDA_BASE = .;
    . = ALIGN(0x4);
  } > data
  .bss : AT (0x04000000 + SIZEOF(.interrupts) + SIZEOF(.text) + SIZEOF(.data))
  {
    __START_SBSS = .;
    * (.sbss)
    *(SCOMMON)
    __END_SBSS = .;
    __START_BSS = .;
    * (.bss)
    * (COMMON)
    __END_BSS = .;
    . = ALIGN(0x4);
  } >> data
  # Heap and Stack sizes definition
  ___heap_size = 0x400;
  ___stack_size = 0x400;
  # 32 Kbytes Internal SRAM
  ___RAMBAR = 0x80000000;
  ___RAMBAR_SIZE = 0x00008000;
  ___SP_AFTER_RESET = ___RAMBAR + ___RAMBAR_SIZE - 4;
  ___SP_SIZE = 0x0400;
  ___HEAP_START = .;
  ___HEAP_END = ___HEAP_START + ___heap_size;
  ___SP_END = ___HEAP_END;
  ___SP_INIT = ___SP_END + ___stack_size;
  ___heap_addr = ___HEAP_START;
  ___heap_size = ___HEAP_END -  ___HEAP_START;
  __SP_INIT = ___SP_INIT;
#  _romp_at = ___ROM_AT + SIZEOF(.data);
  _romp_at = 0x04000000 + 0x8000 ;
  .romp : AT(_romp_at)
  {
    __S_romp = _romp_at;
    WRITEW(0x04000000);
    WRITEW(0x80000000);
    WRITEW(0x7fff);
    WRITEW(0);
    WRITEW(0);
    WRITEW(0);
  }
}
0 项奖励
回复

1,941 次查看
J2MEJediMaster
Specialist I
Look under the (CodeWarrior Examples) directory for some code examples. Specifically, try checking the 5213_PIC\Source directory. It has example code that copies code from ROM to RAM. HTH.

---Tom

0 项奖励
回复

1,941 次查看
Conair0001
Contributor I
Thanks.
Now I found out, that I can place functions into Internal RAM by putting:
 
declspec(RAMcode)
 
in front of the function definition and adding the "RAMcode" area into the data section of the lcf-file
 
Now I would like to put a big array into SDRAM.
 
But putting "declspec(externalram)" in front of the variable definition results in an error:
 
"illegal type qualifier(s) ....__declspec(externalram)...."
 
Can you help me on this also?
 
Thanks,
Konrad.
0 项奖励
回复

1,941 次查看
Arev
Contributor III
Hello,
 
_S_romp structure is defined in the link file (*.lcf) and is used for ROM to RAM copy at Startup.
 
_S_romp structure contains sequence of three word values per entry, the last entry must be 3 NULL words.
{
 ROM Start Address 
 RAM Start Address
 BLOCK Size
 
For software in Flash running from Flash, At Startup the BSP uses _S_romp to copy initilized data from Flash to their Ram location.
 
For software in Flash running from Ram, At Startup the BSP  uses _S_romp to copy the Code from Flash to Ram and initilized data from Flash to RAM.
Hardware Init Code, Vectors, Library Code doing ROM  to RAM copy must stay in Flash as BootCode.

Example of lcf file
 
Code:
#----------------------------------------------------------------------------------------------------------------------##                                           DEFINITION DES "MEMORY SEGMENTS"                                           ## -------------------------------------------------------------------------------------------------------------------- ##        Segment (RWX : Read,Write,eXecute) : ORIGIN = Memory address, LENGTH = Segment size (0x0 = Unlimited)         ##----------------------------------------------------------------------------------------------------------------------#MEMORY{    CPU_IPSBAR          (RWX) : ORIGIN = 0x40000000, LENGTH = 0x0    RAM_SDRAM           (RWX) : ORIGIN = 0x00000000, LENGTH = 0x01000000    RAM_SDRAM_Vecteurs  (RWX) : ORIGIN = 0x00000000, LENGTH = 0x00000400    RAM_SRAM            (RWX) : ORIGIN = 0x20000000, LENGTH = 0x00010000    RAM_SRAM_Vecteurs   (RWX) : ORIGIN = 0x20000000, LENGTH = 0x00000400    RAM_SRAM_Data       (RWX) : ORIGIN = 0x20000400, LENGTH = 0x0000FC00    RAM_ProgSector      (RWX) : ORIGIN = 0x00000000, LENGTH = 0x0    FLASH_BootSector    (RWX) : ORIGIN = 0xFFE00000, LENGTH = 0x00004000    FLASH_Param1Sector  (RWX) : ORIGIN = 0xFFE04000, LENGTH = 0x0    FLASH_Param2Sector  (RWX) : ORIGIN = 0xFFE06000, LENGTH = 0x0    FLASH_EnvSector     (RWX) : ORIGIN = 0xFFE08000, LENGTH = 0x0    FLASH_ProgSector    (RWX) : ORIGIN = 0xFFE10000, LENGTH = 0x0}#----------------------------------------------------------------------------------------------------------------------##                                          DEFINITION DES "SECTIONS SEGMENTS"                                          ## -------------------------------------------------------------------------------------------------------------------- ##          .SectionName : { Section Content } > Puts at the beginning of Memory segment (>> Appends to End)            ##----------------------------------------------------------------------------------------------------------------------#SECTIONS{    #------------------------------------------------------------------------------------------------------------------#    #-                     DECLARATION & AFFECTATION DES "SECTIONS SEGMENTS" AUX "MEMORY SEGMENTS"                    -#    #------------------------------------------------------------------------------------------------------------------#    .RAM_SDRAM        : {} > RAM_SDRAM    .RAM_Vecteurs     : {} > RAM_SRAM_Vecteurs    .CPU_IPSBAR       : {} > CPU_IPSBAR    .RAM_SRAM         : {} > RAM_SRAM    .RAM_SRAM_Data    : {} > RAM_SRAM_Data    .FLASH_BootSector : {} > FLASH_BootSector    .FLASH_ProgSector : {} > FLASH_ProgSector    #------------------------------------------------------------------------------------------------------------------#    #-                          DEFINITION DES SYMBOLES GLOBAUX Utilisés dans l'application                           -#    #------------------------------------------------------------------------------------------------------------------#    ___IPSBAR           = ADDR(.CPU_IPSBAR);    ___VECTOR_RAM       = ADDR(.RAM_Vecteurs);    ___SDRAM            = ADDR(.RAM_SDRAM);    ___SDRAM_SIZE       = 0x01000000;    ___SRAM             = ADDR(.RAM_SRAM);    ___SRAM_SIZE        = 0x00010000;    ___EXT_FLASH        = ADDR(.FLASH_BootSector);    ___EXT_FLASH_SIZE   = 0x00200000;    ___SP_SIZE          = 0x2000;    #------------------------------------------------------------------------------------------------------------------#    #-        TABLE des VECTEURS ROM (Définitions des Vecteurs d'exception et d'interruption de l'application)        -#    # ---------------------------------------------------------------------------------------------------------------- #    #-                         Section Chargée en FLASH, Recopiée en SRAM AT(___VECTOR_RAM)                           -#    #------------------------------------------------------------------------------------------------------------------#    .CODE_Vecteurs :    {        BSP_ColdfireVectors.o   (.text)        . = ALIGN (0x40);    } >> FLASH_BootSector    #------------------------------------------------------------------------------------------------------------------#    #-   BOOTSTART CODE & RUNTIME LIBRARY (Fonctions Initialisation Hardware et Recopie de l'application en SDRAM)    -#    # ---------------------------------------------------------------------------------------------------------------- #    #-                                      Section Chargée & Exécutée en FLASH                                       -#    #------------------------------------------------------------------------------------------------------------------#    .CODE_Boot :    {        BSP_Asm_BootCode.o                      (.text)        BSP_HardwareInit.o                      (.text)        OBJECT(__ExitProcess,                   C_4i_CF_Runtime.a)        OBJECT(_clear_mem,                      C_4i_CF_Runtime.a)        OBJECT(__start,                         C_4i_CF_Runtime.a)        OBJECT(___initialize_hardware,          C_4i_CF_Runtime.a)        OBJECT(___initialize_OS,                C_4i_CF_Runtime.a)        OBJECT(_simple_block_copy,              C_4i_CF_Runtime.a)        OBJECT(___copy_rom_section,             C_4i_CF_Runtime.a)        OBJECT(___copy_rom_sections_to_ram,     C_4i_CF_Runtime.a)        . = ALIGN (0x40);    } >> FLASH_BootSector    __EndOfBootSector = .;    #------------------------------------------------------------------------------------------------------------------#    #-                               EXECUTABLE CODE & READ-ONLY DATA (Code Application)                              -#    # ---------------------------------------------------------------------------------------------------------------- #    #-            Section Chargée en FLASH AT(___CODE_ROM), Recopiée & Executée en SDRAM AT(___CODE_RAM)              -#    #------------------------------------------------------------------------------------------------------------------#    ___CODE_ROM     = ADDR(FLASH_ProgSector);    ___CODE_RAM     = ADDR(RAM_ProgSector);    .text : AT(___CODE_ROM)    {        . = ALIGN (0x4);        *(.text)        . = ALIGN (0x40);        *(.rodata)        . = ALIGN (0x40);    } > RAM_ProgSector    #------------------------------------------------------------------------------------------------------------------#    #-                                                INITIALIZED DATA                                                -#    # ---------------------------------------------------------------------------------------------------------------- #    #-                  Section Chargée en FLASH AT(___DATA_ROM), Recopiée en SDRAM AT(___DATA_RAM)                   -#    #------------------------------------------------------------------------------------------------------------------#    ___DATA_ROM     = ___CODE_ROM + SIZEOF(.text);    ___DATA_RAM     = ADDR(RAM_ProgSector) + SIZEOF(.text);    .data : AT(___DATA_ROM)    {        ___sinit__    = .;        STATICINIT        __START_DATA  = .;        *(.data)        __END_DATA    = .;        __START_SDATA = .;        *(.sdata)        __END_SDATA   = .;        __SDA_BASE    = .;        . = ALIGN (0x40);    } >> RAM_ProgSector    #------------------------------------------------------------------------------------------------------------------#    #-                                       UNINITIALIZED DATA CLEARED TO ZERO                                       -#    # ---------------------------------------------------------------------------------------------------------------- #    #-                                            Section Chargée en SDRAM                                            -#    #------------------------------------------------------------------------------------------------------------------#    .bss :    {        __START_SBSS  = .;        *(.sbss)        *(SCOMMON)        __END_SBSS    = .;        __START_BSS   = .;        *(.bss)        *(COMMON)        __END_BSS     = .;        . = ALIGN(0x4);    } >> RAM_ProgSector    #------------------------------------------------------------------------------------------------------------------#    #-       DEFINITION du HEAP MEMOIRE & PILE SYSTEME PROVISOIRE (PILE modifiée par CMX RTOS dans CMX_INIT.C)        -#    # ---------------------------------------------------------------------------------------------------------------- #    #-                                            Section Chargée en SDRAM                                            -#    #------------------------------------------------------------------------------------------------------------------#    .custom :    {        . = ALIGN(0x4);        ___HEAP_START   = .;        ___HEAP_END     = ___SDRAM + ___SDRAM_SIZE - ___SP_SIZE;        ___SP_END       = ___HEAP_END;        ___SP_INIT      = ___SP_END + ___SP_SIZE;        ___SP_INIT_SRAM = ___SRAM + ___SRAM_SIZE;    # Pile Temporaire de Démmarage en SRAM        ___SP_INIT      = ___SP_INIT_SRAM;        . = ALIGN (0x4);    } >> RAM_ProgSector    ___heap_addr    = ___HEAP_START;    ___heap_size    = ___HEAP_END - ___HEAP_START ;    __SP_INIT       = ___SP_INIT;    #------------------------------------------------------------------------------------------------------------------#    #-         TABLE de RECOPIE de la ROM vers la RAM utilisée par le code de démarrage de la RUNTIME LIBRARY         -#    # ---------------------------------------------------------------------------------------------------------------- #    #-    __S_romp = Séquence de 3 Words par section à recopier, la dernière section de la table doit être à zéro     -#    #-                                                                                                                -#    #-     Section à recopier = { ROM Start Address                                                                   -#    #-                            RAM Start Address                                                                   -#    #-                            BLOCK Size                                                                          -#    #-                          }                                                                                     -#    #------------------------------------------------------------------------------------------------------------------#    _romp_at = ___DATA_ROM + SIZEOF(.data);    .romp : AT(_romp_at)    {        __S_romp = _romp_at;        WRITEW(___CODE_ROM);        # FLASH CODE Address        WRITEW(___CODE_RAM);        # SDRAM CODE Address        WRITEW(SIZEOF(.text));      # CODE  Size        WRITEW(___DATA_ROM);        # FLASH Initialized DATA Address        WRITEW(___DATA_RAM);        # SDRAM Initialized DATA Address        WRITEW(SIZEOF(.data));      # DATA  Size        WRITEW(0);                  # NULL  Last Entry        WRITEW(0);                  # NULL  Last Entry        WRITEW(0);                  # NULL  Last Entry    }}

I Hope this helps..

Bye
 
<< Freescale MCF5234/35 with CodeWarrior 6.2 >>
0 项奖励
回复

1,941 次查看
Conair0001
Contributor I
Thanks,
 
that was great help.
 
Now I have some other Problem.
 
I put 1 data-array into SDRAM and I use SDRAM only for this array.
If I load my Program into Flash and power-cycle my EVB, it seems like the Data in the SDRAM array is corrupted it contains only garbage, but the rest of the program works well.
 
However if I start the program from Flash but with the Code-Warrior Debugger, then it works fine.
 
I noticed there is some initialisation code in the .cfg file.
Is this only executed when I'm using the debugger?
 
Where do I have to put this that it initializes also when I'm running without the debugger?
 
Thanks and best regards,
Konrad.
0 项奖励
回复

1,941 次查看
Arev
Contributor III
Hello,
 
On my target MCF523x, the Bootcode checks if SDRAM controller is already initialized before performing initialisation.
So in Debug Mode, SDRAM Controller Initialisation is done by the debbuger with cfg file and the bootcode skip it.
In Release Mode, your bootcode must initialize the SDRAM controller.
 
In debug, you can analyse the boot sequence to find where SDRAM Controller initialization is done or skipped.

Bye,

<< Freescale MCF5234/35 with CodeWarrior 6.2 >>
0 项奖励
回复