External RAM setup

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

External RAM setup

Jump to solution
3,268 Views
Mohsin455
Contributor IV

Hi All,

          I am using K60N512, MQX3.8 and IAR tools. I am using external RAM in my custom board and it works fine. Now I want to add a new section to my linker file so that I can store the data of my choice in external RAM. I have added a new section EXTERNAL_RAM as below. But when I use this linker file, the board does not boot. It looks like somehow the vectors are not being populated correctly. Can anyone please advise the what could be wrong ?



define memory mem with size = 4G;

define region ROM_region   = mem:[from __ICFEDIT_region_ROM_start__   to __ICFEDIT_region_ROM_end__];

define region RAM_region   = mem:[from __ICFEDIT_region_RAM_start__   to __ICFEDIT_region_RAM_end__];

define region ERAM_region  = mem:[from __EXTERNAL_RAM_BASE to __EXTERNAL_RAM_END ];     /* External RAM section */

define block KERNEL_DATA with alignment = 8 { section .kernel_data };

define exported symbol __FLASHX_SECT_SIZE = 0x800;

define exported symbol __FLASHX_END_ADDR = __INTERNAL_FLASH_BASE + __INTERNAL_FLASH_SIZE;

define block CFMPROTROM with size = 20 { section .cfmconfig };

define block FLASHX_POOL with alignment = __FLASHX_SECT_SIZE { section .flashx };

define block TEXTSECTION with alignment = 4 { section .text };

keep { section .cfmconfig };

keep { section .flashx };

initialize by copy { readwrite };

do not initialize  { section .noinit };

do not initialize  { section .kernel_data };

do not initialize  { section .flashx };

place at address mem:__ICFEDIT_intvec_start__ { readonly section .intvec, block CFMPROTROM };

place in ROM_region { first block TEXTSECTION, readonly,  last block FLASHX_POOL };

place at address mem:__ICFEDIT_region_RAM_start__ { readwrite section .vectors_ram };

place in ERAM_region  { section EXTERNAL_RAM };        /* External RAM section */

/* each block/segment must be in one line (association to region) because I need kernel data start after other datas */

place in RAM_region   { readwrite, last block KERNEL_DATA };


Thanks,

Mohsin

0 Kudos
Reply
1 Solution
1,483 Views
Mohsin455
Contributor IV

Hi All,

            I was initialising the external RAM at a very late stage. It has to be initialised in _low_level_init(). It all wokring fine and the above linker file is correct.

Mohsin

View solution in original post

0 Kudos
Reply
3 Replies
1,483 Views
KJFPE
Contributor III

Hi Mohsin

Have you defined the  __External_RAM _BASE and __External_RAM_END

I.e. in the ICF file (whatever your address are and memory size)

define exported symbol __EXTERNAL_RAM_BASE          = 0x70000000;
define exported symbol __EXTERNAL_RAM_SIZE            = 0x00200000;                    //2 M

define region ERAM_region =  mem:[from __EXTERNAL_RAM_BASE to __External_RAM_END]

0 Kudos
Reply
1,483 Views
Mohsin455
Contributor IV

Yes,

        I have already defined that. Below is my full linker file. As I add the code marked in BOLD, the program does not even go to _low_level_init().

/*###ICF### Section handled by ICF editor, don't touch! ****/

/*-Editor annotation file-*/

/* IcfEditorFile="$TOOLKIT_DIR$\config\ide\IcfEditor\cortex_v1_0.xml" */

/*-Specials-*/

define symbol __ICFEDIT_intvec_start__ = 0x0000c800;

/*-Memory Regions-*/

define symbol __ICFEDIT_region_ROM_start__   = 0x0000cc20 ;

define symbol __ICFEDIT_region_ROM_end__     = 0x0007F7FF;

define symbol __ICFEDIT_region_RAM_start__   = 0x1fff0000;

define symbol __ICFEDIT_region_RAM_end__     = 0x2000FFF0;

/*-Sizes-*/

define symbol __ICFEDIT_size_cstack__   = 0x00;

define symbol __ICFEDIT_size_heap__     = 0;

/**** End of ICF editor section. ###ICF###*/

define exported symbol __EXTERNAL_MRAM_ROM_BASE = 0x70000000;

define exported symbol __EXTERNAL_MRAM_ROM_SIZE = 0x00000000;

define exported symbol __EXTERNAL_MRAM_RAM_BASE = 0x70000000;

define exported symbol __EXTERNAL_MRAM_RAM_SIZE = 0x00080000;

define exported symbol __EXTERNAL_LCD_BASE = 0x60000000;

define exported symbol __EXTERNAL_LCD_SIZE = 0x1FFFF;

define exported symbol __EXTERNAL_LCD_DC_BASE = 0x60010000;

define exported symbol __INTERNAL_FLASH_BASE = 0x0000c800;

define exported symbol __INTERNAL_FLASH_SIZE = 0x00073000;

define exported symbol __EXTERNAL_RAM_BASE = 0x70000000;    /* External RAM */

define exported symbol __EXTERNAL_RAM_SIZE = 0x00010000;    /* External RAM */

define exported symbol __EXTERNAL_RAM_END  = 0x7000FFFF;    /* External RAM */

define exported symbol __INTERNAL_FLEXNVM_BASE = 0;

define exported symbol __INTERNAL_FLEXNVM_SIZE = 0;

define exported symbol __VECTOR_TABLE_ROM_START = 0x0000c800;

define exported symbol __VECTOR_TABLE_RAM_START = __ICFEDIT_region_RAM_start__;

define exported symbol __DEFAULT_PROCESSOR_NUMBER = 1;

define exported symbol __DEFAULT_INTERRUPT_STACK_SIZE = 1024;

/* mem_init writes a storeblock_struct at the end of kernel data, max size 32 bytes, so use 0x100 offset */

define exported symbol __BOOT_STACK_ADDRESS = __ICFEDIT_region_RAM_end__ - 0x100;

define exported symbol __KERNEL_DATA_END = __ICFEDIT_region_RAM_end__;

define memory mem with size = 4G;

define region ROM_region   = mem:[from __ICFEDIT_region_ROM_start__   to __ICFEDIT_region_ROM_end__];

define region RAM_region   = mem:[from __ICFEDIT_region_RAM_start__   to __ICFEDIT_region_RAM_end__];

define region ERAM_region  = mem:[from __EXTERNAL_RAM_BASE to __EXTERNAL_RAM_END ];     /* External RAM section */

define block KERNEL_DATA with alignment = 8 { section .kernel_data };

define exported symbol __FLASHX_SECT_SIZE = 0x800;

define exported symbol __FLASHX_END_ADDR = __INTERNAL_FLASH_BASE + __INTERNAL_FLASH_SIZE;

define block CFMPROTROM with size = 20 { section .cfmconfig };

define block FLASHX_POOL with alignment = __FLASHX_SECT_SIZE { section .flashx };

define block TEXTSECTION with alignment = 4 { section .text };

keep { section .cfmconfig };

keep { section .flashx };

initialize by copy { readwrite };

do not initialize  { section .noinit };

do not initialize  { section .kernel_data };

do not initialize  { section .flashx };

place at address mem:__ICFEDIT_intvec_start__ { readonly section .intvec, block CFMPROTROM };

place in ROM_region { first block TEXTSECTION, readonly,  last block FLASHX_POOL };

place at address mem:__ICFEDIT_region_RAM_start__ { readwrite section .vectors_ram };

place in ERAM_region  { section EXTERNAL_RAM };        /* External RAM section */

/* each block/segment must be in one line (association to region) because I need kernel data start after other datas */

place in RAM_region   { readwrite, last block KERNEL_DATA };


0 Kudos
Reply
1,484 Views
Mohsin455
Contributor IV

Hi All,

            I was initialising the external RAM at a very late stage. It has to be initialised in _low_level_init(). It all wokring fine and the above linker file is correct.

Mohsin

0 Kudos
Reply