I'm running the code from FLASH currently, but want to speed things up by copying the code to RAM at boot up and executing there. What do I have to change in the  linker file to have the boot code in FLASH copy the executable to RAM and jump there?

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

I'm running the code from FLASH currently, but want to speed things up by copying the code to RAM at boot up and executing there. What do I have to change in the  linker file to have the boot code in FLASH copy the executable to RAM and jump there?

2,307 Views
ASHISH26
Contributor I

I'm running the code from FLASH currently, but want to speed things up by copying the code to RAM at boot up and executing there. What do I have to change in the CodeWarrior project settings and/or linker file to have the boot code in FLASH copy the executable to RAM and jump there?


MEMORY {

/* section allocation */

/* exception_handlers:             org=0x40000000, len=0x00001000 */

FLASH_BTL_LOW        : org = 0x00000000, len =  0x4000

FLASH_BTL_HIGH       : org = 0x00040000, len =  0x20000

FLASH_EEPROM         : org = 0x00004000, len =  0x18000

FLASH_NIA_LOGISTIC   : org = 0x0001C000, len =  0x4000

FLASH_DATASET        : org = 0x00020000, len =  0x10000

FLASH_VC_PARAMETER   : org = 0x00030000, len =  0x5000

FLASH_CC_PARAMETER   : org = 0x00035000, len =  0x6000

FLASH_GS_PARAMETER   : org = 0x0003B000, len =  0x4F00

FLASH_SW_SIGNATURE   : org = 0x0003FF00, len =  0x100

/* FLASH_RESERVED_FLASH : org = 0x00060000, len =  0x20000 */

/* @todo split of default data for FR / CAN Stack etc..*/

FLASH_NIA_CHILI_INT  : org = 0x00060000, len =  0x2000

FLASH_NIA_CHILI_PARAM: org = 0x00064000, len =  0x4000

FLASH_NIA_CHILI      : org = 0x00080000, len =  0x40000

/* FLASH_AUTOSAR_QM     : org = 0x000B6000, len =  0xA000 */

FLASH_CC_CODE        : org = 0x000C0000, len =  0x20000

FLASH_VC_CODE        : org = 0x000E0000, len =  0x10000

FLASH_GS_CODE        : org = 0x000F0000, len =  0x10000

 

/* @todo RAM segmentation */

/* RAM_AUTOSAR_QM       : org = 0x40000000, len =  0x2000  */

/* RAM_NIA_CHILI        : org = 0x40002000, len =  0x4400  */

/* RAM_CC               : org = 0x40006400, len =  0x2800  */

/* RAM_VC               : org = 0x40008C00, len =  0x2000  */

/* RAM_GS               : org = 0x4000AC00, len =  0x1000  */

RAM_ALL              : org = 0x40000000, len =  0x4000

RAM_SBL              : org = 0x40004000, len =  0x7C00

RAM_STACK            : org = 0x4000BC00, len =  0x4000

RAM_RST_SAFE         : org = 0x4000FC00, len =  0x3C0

RST_SAFE_BTL_APP     : org = 0x4000FFC0, len =  0x40

RAM_FLEXRAY          : org = 0x50000000, len =  0x8000

 

}

 

 

SECTIONS {

 

 

    .resetword : {} > FLASH_BTL_LOW

    .mpt_startup : {} > FLASH_BTL_LOW

 

 

    GROUP : {

        .intvectcode : {}

        /* This is a dummy section to satisfy the linker for vle!*/

        /* This section should not contain any code.             */

        .text_e (TEXT) : {

            *(.text)

            . = (.+15) & ~15;

        }

        .text (TEXT) : {

            *(.text) *(.text_vle) *(.rodata) *(.init) *(.fini) *(.eini) *(.ctors) *(.dtors)

            . = (.+15) & ~15;

/* Safe Context "Store of symbols in Flash" */

            STORE(ADDR(.ossAppliDataAll_Trusted), 4)

            STORE(_ossAppliData_LOADADDR_All_Trusted, 4)

            STORE(_ossAppliData_SIZE_All_Trusted, 4)

            STORE(ADDR(.ossAppluDataAll_Trusted), 4)

            STORE(0, 4)

            STORE((SIZEOF(.ossAppluDataAll_Trusted) +31) &~31, 4)

            STORE(ADDR(.ossAppliSDADataAll_Trusted), 4)

            STORE(_ossAppliSDAData_LOADADDR_All_Trusted, 4)

            STORE(_ossAppliSDAData_SIZE_All_Trusted, 4)

            STORE(ADDR(.ossAppluSDADataAll_Trusted), 4)

            STORE(0, 4)

            STORE((SIZEOF(.ossAppluSDADataAll_Trusted) +31) &~31, 4)

        }

/* Safe Context "Store of symbols in Flash" */

        .sdata2 (TEXT) : {}

 

 

/* Safe Context Location of Flash data */

        .textCfg (CONST):{

          *(.os_sConfigBlock)

          *(.os_sConfigBlock2)         

          *(.os_ConfigBlock)

          *(.os_ConfigBlock2)

        }

 

 

        .oscode(TEXT) : {}

        .osSCTXcode(TEXT) : {}

        .osTfCallerStub_code(TEXT) : {}

        .osTfCalleeStub_code(TEXT) : {}

        .osconst(CONST) : {}

        .osuconst(CONST) : {}

        .osSCTXconst(CONST) : {}

        .osSCTXuconst(CONST) : {}

        .ossconst(CONST) : {}

        .ossuconst(CONST) : {}

        .osSCTXsconst(CONST) : {}

        .osSCTXsuconst(CONST) : {}

/* Safe Context Location of Flash data End */

 

 

        .bsw_nia_code (TEXT) : {}

        .bsw_nia_sconst (CONST) : {}

        .bsw_nia_suconst (CONST) : {}

    } > FLASH_BTL_HIGH

   

    GROUP : {

        .bsw_nia_version (CONST) : {}

        .bsw_nia_const (CONST) : {}

        .bsw_nia_uconst (CONST) : {}

        .btl_nia_code (TEXT) : {}

        .btl_nia_sconst (CONST) : {}

        .btl_nia_suconst (CONST) : {}

        .btl_nia_version (CONST) : {}

        .btl_nia_const (CONST) : {}

        .btl_nia_uconst (CONST) : {}   

   __DATA_ROM = .;

         _load_sdata0  = . ;

         _load_sdabase = _load_sdata0  + SIZEOF(.sdata0)  ;

         _load_sdata   = _load_sdabase + SIZEOF(.sdabase) ;

         _load_data    = _load_sdata   + SIZEOF(.sdata)   ;

         _load_btl_nia_data  = _load_data + SIZEOF(.data)                  ;

         _load_btl_nia_sdata = _load_btl_nia_data + SIZEOF(.btl_nia_data)  ;

         _load_bsw_nia_data  = _load_btl_nia_sdata + SIZEOF(.btl_nia_sdata) ;

         _load_bsw_nia_sdata = _load_bsw_nia_data + SIZEOF(.bsw_nia_data)  ;

         _load_cc_data  = _load_bsw_nia_sdata + SIZEOF(.bsw_nia_sdata) ;

         _load_cc_sdata = _load_cc_data + SIZEOF(.cc_data)  ;

         _load_vc_data  = _load_cc_sdata + SIZEOF(.cc_sdata) ;

         _load_vc_sdata = _load_vc_data + SIZEOF(.vc_data)  ;

         _load_gs_data  = _load_vc_sdata + SIZEOF(.gs_data);

         _load_gs_sdata = _load_gs_data + SIZEOF(.gs_sdata)  ;

         __DATA_ROM_START = _load_data + SIZEOF(.data); 

    } > FLASH_BTL_LOW

 

 

    GROUP : {

        .bsw_nia_version (CONST) : {}

        .bsw_nia_const (CONST) : {}

        .bsw_nia_uconst (CONST) : {}

    } > FLASH_NIA_CHILI_PARAM

   

    GROUP : {

        .bsw_nia_sconst_crc (CONST) : {}

        .bsw_nia_const_crc (CONST) : {}

        .bsw_nia_suconst_crc (CONST) : {}

        .bsw_nia_uconst_crc (CONST) : {}

    } > FLASH_SW_SIGNATURE

 

 

    GROUP : {

     .osisrvectbl : {}

     .osisrwrapper : {}

     .intvecttable : {}

     .mpt_exceptions : {}

    } >FLASH_NIA_CHILI_INT

 

 

    GROUP : {

     .bsw_nia_parameter (=NOLOAD): {}

    } >FLASH_NIA_LOGISTIC

 

 

    GROUP : {

      FLASHDRV (BSS) : {}

      __DATA_RAM = .;

      .sdata0(DATA) LOAD(_load_sdata0) : {}

      .sdabase ALIGN(8) LOAD(_load_sdabase)   : {}

      .sdata (DATA) LOAD(_load_sdata) : {}

      .data (DATA) LOAD(_load_data) : {}

      .btl_nia_data (DATA) LOAD(_load_btl_nia_data): {}

      .bsw_nia_data (DATA) LOAD(_load_bsw_nia_data): {}

      .btl_nia_sdata (DATA) LOAD(_load_btl_nia_sdata) : {}

      .bsw_nia_sdata (DATA) LOAD(_load_bsw_nia_sdata) : {}

      .cc_data (DATA) LOAD( _load_cc_data) : {}

      .cc_sdata (DATA) LOAD( _load_cc_sdata) : {}

      .vc_data (DATA) LOAD( _load_vc_data) : {}

      .vc_sdata (DATA) LOAD( _load_vc_sdata) : {}

      .gs_data (DATA) LOAD( _load_gs_data) : {}

      .gs_sdata (DATA) LOAD( _load_gs_sdata) : {}

      .btl_nia_sudata (DATA): {}

      .bsw_nia_sudata (DATA): {}

      .btl_nia_udata (DATA): {}

      .bsw_nia_udata (DATA): {}

      .cc_udata (BSS): {}

      .cc_sudata (BSS): {}

      .vc_udata (BSS): {}

      .vc_sudata (BSS): {}

      .sbss  (BSS) : {}

      .bss   (BSS) : {}

 

 

/* Safe Context OS data */

        _INIT_SIZE = 0;

        _ossDataStart = ALIGN(32);

        .osdata  (DATA) ALIGN(32) : {}

        .osudata (DATA) ALIGN(32) : {}

        _ossDataEnd = .-1;

/* Safe Context OS data End */

/* Safe Context OS short data */

        _ossSDADataStart = ALIGN(32);

        .ossdata (DATA) ALIGN(32): {}

        .ossudata ALIGN(32) : {}

        _ossSDADataEnd = .-1;

/* Safe Context OS short data END */

/* Safe Context OS Safe data */

        .osSCTXdata  (DATA) ALIGN(32) : {}

        .osSCTXudata (DATA) ALIGN(32) : {}

/* Safe Context OS Safe data END */

/* Safe Context OS Safe sdata */

        _ossSCTXiSDAData_LOADADDR_ =  __DATA_ROM_START + _INIT_SIZE;

        .osSCTXsdata(DATA) ALIGN(32) LOAD(_ossSCTXiSDAData_LOADADDR_): {}

        .osSCTXsudata (DATA) ALIGN(32) : {}

/* Safe Context OS Safe sdata END */

/* Safe Context OS Global Shared data */

      _ossSDADataStartGlobalShared = ALIGN(32);

      _ossiSDADataStartGlobalShared = ALIGN(32);

      _ossiSDAData_LOADADDR_GlobalShared =  __DATA_ROM_START + _INIT_SIZE;

      .ossiSDADataGlobalShared(DATA) ALIGN(32) LOAD(_ossiSDAData_LOADADDR_GlobalShared): {}

      _ossiSDAData_SIZE_GlobalShared=  (SIZEOF(.ossiSDADataGlobalShared) + 31) & ~31;

      _INIT_SIZE += _ossiSDAData_SIZE_GlobalShared;

      _ossiSDADataEndGlobalShared = .-1;

      _ossuSDADataStartGlobalShared = ALIGN(32);

      .ossuSDADataGlobalShared ALIGN(32) : {}

      _ossuSDADataEndGlobalShared = .-1;

      _ossSDADataEndGlobalShared = .-1;

/* Safe Context OS Global Shared data End */

 

 

/* Safe Context SDAdata */

        . = (. + 31) & ~31;

        _ossApplSDADataStartAll_Trusted = ALIGN(32);

        _ossAppliSDADataStartAll_Trusted = ALIGN(32);

        _ossAppliSDAData_LOADADDR_All_Trusted =  __DATA_ROM_START + _INIT_SIZE;

        .ossAppliSDADataAll_Trusted(DATA) ALIGN(32) LOAD(_ossAppliSDAData_LOADADDR_All_Trusted): {}

        _ossAppliSDAData_SIZE_All_Trusted=  (SIZEOF(.ossAppliSDADataAll_Trusted) + 31) & ~31;

        _INIT_SIZE += _ossAppliSDAData_SIZE_All_Trusted;

        _ossAppliSDADataEndAll_Trusted = .-1;

        . = (. + 31) & ~31;

        _ossAppluSDADataStartAll_Trusted = ALIGN(32);

        .ossAppluSDADataAll_Trusted ALIGN(32) : {}

        _ossAppluSDADataEndAll_Trusted = .-1;

        _ossApplSDADataEndAll_Trusted = .-1;

/* Safe Context SDADATA End */

 

 

/* Safe Context DATA */

        . = (. + 31) & ~31;

        _ossApplDataStartAll_Trusted = ALIGN(32);

        _ossAppliDataStartAll_Trusted = ALIGN(32);

        _ossAppliData_LOADADDR_All_Trusted =  __DATA_ROM_START + _INIT_SIZE;

        .ossAppliDataAll_Trusted(DATA) ALIGN(32) LOAD(_ossAppliData_LOADADDR_All_Trusted): {}

        _ossAppliData_SIZE_All_Trusted=  (SIZEOF(.ossAppliDataAll_Trusted) + 31) & ~31;

        _INIT_SIZE += _ossAppliData_SIZE_All_Trusted;

        _ossAppliDataEndAll_Trusted = .-1;

        . = (. + 31) & ~31;

        _ossAppluDataStartAll_Trusted = ALIGN(32);

        .ossAppluDataAll_Trusted ALIGN(32) : {}

        _ossAppluDataEndAll_Trusted = .-1;

        _ossApplDataEndAll_Trusted = .-1;

/* Safe Context DATA End */

 

 

        .ossAppluSDADataOsApplication_QM ALIGN(32) : {}

        .ossAppliSDADataOsApplication_QM ALIGN(32) : {}

        .ossAppluDataOsApplication_QM ALIGN(32) : {}

 

 

/* Safe Context RAM_STACK */

        . = (. + 31) & ~31;

        _ossTaskStackStartCDD_Cyclic_1msTask = ALIGN(32);

        .ossTaskStackCDD_Cyclic_1msTask ALIGN(32)(BSS) : {}

        . = (. + 31) & ~31;

        _ossTaskStackEndCDD_Cyclic_1msTask = . - 1;

        . = (. + 31) & ~31;

        _ossTaskStackStartFR_SynchTask = ALIGN(32);

        .ossTaskStackFR_SynchTask ALIGN(32)(BSS) : {}

        . = (. + 31) & ~31;

        _ossTaskStackEndFR_SynchTask = . - 1;

        . = (. + 31) & ~31;

        _ossTaskStackStartCDD_Cyclic_10msTask = ALIGN(32);

        .ossTaskStackCDD_Cyclic_10msTask ALIGN(32)(BSS) : {}

        . = (. + 31) & ~31;

        _ossTaskStackEndCDD_Cyclic_10msTask = . - 1;

        . = (. + 31) & ~31;

        _ossTaskStackStartBackgroundTask = ALIGN(32);

        .ossTaskStackBackgroundTask ALIGN(32)(BSS) : {}

        . = (. + 31) & ~31;

        _ossTaskStackEndBackgroundTask = . - 1;

/* Safe Context RAM_STACK End */

 

 

    } >RAM_ALL

 

 

    GROUP : {

            .frmdata (BSS) : {}

    } > RAM_FLEXRAY

 

 

   

    GROUP : {

        .osstack (BSS) : {}

    } > RAM_STACK

 

 

/* Safe Context OS Stacks (System Level) */

    GROUP : {

        .osstacksys (BSS) : {}

    } > RAM_STACK

 

    GROUP : {

        .osstackidl (BSS) : {}

    } > RAM_STACK

/* Safe Context OS RAM_STACK (System Level) End */

 

 

        /* Any space left over will be used as a heap */

 

 

    GROUP:

    {

        .bsw_nia_reset_safe(DATA) : {}

    } > RAM_RST_SAFE

   

    GROUP:

    {

        .btl_nia_reset_safe(DATA) : {}

    } > RST_SAFE_BTL_APP

}

 

 

/* Definitions of identifiers used by sbrk.c, init.c and the different

* crt0.s files. Their purpose is to control initialization and memory

* allocation.

*

* __HEAP_START : Used by sbrk.c. Start of memory used by malloc() etc.

* __HEAP_END   : Used by sbrk.c. End of heap memory

* __SP_INIT    : Used by crt0.s. Initial address of RAM_STACK pointer

* __SP_END     : Used by sbrk.c. Only used when RAM_STACK probing

* __DATA_ROM   : Used by init.c. Address of initialized data in ROM

* __DATA_RAM   : Used by init.c. Address of initialized data in RAM

* __DATA_END   : Used by init.c. End of allocated initialized data

* __BSS_START  : Used by init.c. Start of uninitialized data

* __BSS_END    : Used by init.c. End of data to be cleared

* ---------------------------------------------------------------------- */

 

 

RST_SAFE_START  = ADDR(RAM_RST_SAFE);

RST_SAFE_SIZE   = SIZEOF(RAM_RST_SAFE);

RC_SDATA_SRC    = _load_sdata;

RC_SDATA_DEST   = ADDR(.sdata);

RC_SDATA_SIZE   = (SIZEOF(.sdata)+3) / 4;

 

 

NIA_DATA_SRC    = _load_bsw_nia_data;

NIA_DATA_DEST   = ADDR(.bsw_nia_data);

NIA_DATA_SIZE   = (SIZEOF(.bsw_nia_data) +3) / 4;

NIA_SDATA_SRC    = _load_bsw_nia_sdata;

NIA_SDATA_DEST   = ADDR(.bsw_nia_sdata);

NIA_SDATA_SIZE   = (SIZEOF(.bsw_nia_sdata) +3) / 4;

 

 

NIA_BTL_DATA_SRC    = _load_btl_nia_data;

NIA_BTL_DATA_DEST   = ADDR(.btl_nia_data);

NIA_BTL_DATA_SIZE   = (SIZEOF(.btl_nia_data) +3) / 4;

NIA_BTL_SDATA_SRC    = _load_btl_nia_sdata;

NIA_BTL_SDATA_DEST   = ADDR(.btl_nia_sdata);

NIA_BTL_SDATA_SIZE   = (SIZEOF(.btl_nia_sdata) +3) / 4;

 

 

 

 

__HEAP_START    = ADDR(.bss)+SIZEOF(.bss);

__HEAP_END      = ADDR(RAM_ALL)+SIZEOF(RAM_ALL);

__SP_INIT       = ADDR(RAM_STACK);

__SP_END        = ADDR(RAM_STACK)+SIZEOF(RAM_STACK);

__DATA_END      = ADDR(.sdata)+SIZEOF(.sdata);

__BSS_START     = ADDR(.sbss);

__BSS_END       = ADDR(.bss)+SIZEOF(.bss);

 

 

/* Some targets use an extra underscore in front of identifiers

* ---------------------------------------------------------------------- */

___HEAP_START   = __HEAP_START;

___HEAP_END     = __HEAP_END;

___SP_INIT      = __SP_INIT;

___SP_END       = __SP_END;

___DATA_ROM     = __DATA_ROM;

___DATA_RAM     = __DATA_RAM;

___DATA_END     = __DATA_END;

___BSS_START    = __BSS_START;

___BSS_END      = __BSS_END;

/* ---------------------------------------------------------------------- */

Labels (1)
Tags (3)
0 Kudos
Reply
5 Replies

1,742 Views
marius_grigoras
NXP Employee
NXP Employee

Hi,

Can you please tell us what CW product are you using and also the board/processor name?

For example, all PA board supports already have some ROM examples that reallocate the .data, .bss in RAM, but the code (.text, .rodata, .intvec remains in ROM).

Thank you,

Marius

0 Kudos
Reply

1,742 Views
ASHISH26
Contributor I

HI,

Thanks for your reply.I am using MPC5643l processsor.could please tell me, should I make in linker file shown in last message.

Thank you,

Ashish

0 Kudos
Reply

1,742 Views
lunminliang
NXP Employee
NXP Employee

Hi, I am not very clear about your case. Anyway, Here are some information may be helpful for you in the section "Building a ROM Image" of C:\Program Files\Freescale\CW PA v10.x\PA\Help\PDF\Power Arch Build Tools Reference-Eclipse.pdf.


If you can describe more detail, it would help me to understand. Are you using yourself bootloader? Do you want your code running from RAM only when you connecting CodeWarrior to your board with TAP for debug or you want it running from RAM without debugger connected? And what is your target device?

0 Kudos
Reply

1,742 Views
ASHISH26
Contributor I

Hi Llunminliang,

Thanks for helpful reply. I want to run my code from ram without using debugger for mpc5643l processor.Could you please help me for this.

Thanks,

Ashish


0 Kudos
Reply

1,742 Views
lunminliang
NXP Employee
NXP Employee

Thanks for the information. I've contacted my colleague who is doing MPC5 seriers, hope she can help.

0 Kudos
Reply