Kinetis K20 Dflash using like PFlash for extra memory program???

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

Kinetis K20 Dflash using like PFlash for extra memory program???

1,403 Views
night
Contributor II

Hi,

I'm working with Kinetis K20 with two memory banks. In a hand it has 256 KB of Pflash for code program. In the other hand it has 32 KB of NVM that can be configurated like EEEProm memory.

If I use 1 KB of EEEProm memmory (16 KB of FlexNVM). Can I use the other 16 KB of flexNVM for PFlash?

I use bootloader for my application too.

Is it possible? In this case, will it run fine with the bootloader?

Thanks. Best regards,

Miguel.

Labels (1)
0 Kudos
10 Replies

808 Views
Kan_Li
NXP TechSupport
NXP TechSupport

Hi Miguel,

Yes, you may use the other 16KB as PFlash, but please note in the linker file you have to define two seperate sections for them instead of one section, becase their address are not continuous.

Hope that helps,

B.R

Kan

0 Kudos

808 Views
night
Contributor II

Dear Kan,

thanks for your answer. I'm trying it, but it returns "overflow in segment: code from section: .txt Segment reserved size..."

could you write here a example where I can see how white the new section?

Very thanks again for your answer.

Best regards,

  Miguel.

0 Kudos

808 Views
Kan_Li
NXP TechSupport
NXP TechSupport

Hi Miguel,

Are you using CW 10.4? For CW, the linker file should be like that:

1.First you have to define two memories for 256KB PFlash and 16KB FlexNVM each.

MEMORY

{

    rom    (RX) : ORIGIN = 0x00000000,  LENGTH = 0x00040000 //256KB

    rom1    (RX) : ORIGIN = 0x10000000,  LENGTH = 0x00004000 //16KB

    ram    (RW) : ORIGIN = 0x1FFF0410,  LENGTH = 0x00007BF0

}

2.Then you may define different sections that place into different memory.

SECTIONS

{

    __VECTOR_RAM      = 0x1FFF0000;

 

    .text :

    {

  . = ALIGN(0x10);

.....

    } > rom

.text1 :

    {

  . = ALIGN(0x10);

  .....

    } > rom1

...

}

Please kindly refer to the attachment for more details.

B.R

Kan

808 Views
night
Contributor II

Hi Kan,

I'm working with CW 10.3. I try with your code, but the problem is the same. I add the memory and section codes.

It reported me:

"Overflow in segment: code from section: .text Segment reserved size is: 0x0003f000 -- Overflow of: 0x00001d34 "

It doesn't recognize the new size of the code.

I attached you the complete file below.

Please, help me.

Very thanks again. Best regard,

Miguel

-------------------------------------------------------------------------------------

## ###################################################################

####

####     THIS COMPONENT MODULE IS GENERATED BY THE TOOL. DO NOT MODIFY IT.

####                                               

####     Filename  : ProcessorExpert.lcf               

####                                               

####     Project   : ProcessorExpert                  

####                                               

####     Processor : MK20DX256VLL7                   

####                                               

####     Compiler  : CodeWarrior ARM C Compiler                   

####                                               

####     Date/Time : 2013-03-18, 13:58, # CodeGen: 54                    

####                                               

####     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 compiler 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 component and then modify this file as needed.

####

####                                               

#### ###################################################################

KEEP_SECTION { .vectortable }

KEEP_SECTION { .cfmconfig }

MEMORY {

  code        (RX) : ORIGIN = 0x00000400, LENGTH = 0x0003F000

  code1       (RX) : ORIGIN = 0x10000000, LENGTH = 0x00004000   //<<<---------------------------------

  data        (RW) : ORIGIN = 0x1FFF8010, LENGTH = 0x0000FFEF

  cfmprotrom  (RX) : ORIGIN = 0x00010400, LENGTH = 0x00000010

 

}

SECTIONS {

  ## Heap and Stack sizes definition

  __heap_size = 0x0800;

  ___stack_size = 0x0800;

  .interrupts :

  {

    __vector_table = .;

    * (.vectortable)

    . = ALIGN (0x4);

  } > interrupts

  .cfmprotect :

  {

    *(.cfmconfig)

    . = ALIGN (0x4);

  } > cfmprotrom

  .text :

  {

    * (.text)

    . = ALIGN(0x4);

    * (.rodata)

    . = ALIGN(0x4);

    ___ROM_AT = .;

    ___DATA_ROM = .;

  } > code

.text1 :               //<<<---------------------------------

  {

    * (.text1)

    . = ALIGN(0x4);

    * (.rodata)

    . = ALIGN(0x4);

    ___ROM_AT = .;

    ___DATA_ROM = .;

  } > code1

 

  .data : AT(___ROM_AT)

  {

    ___DATA_RAM = .;

    * (.ARM.extab)

    . = 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_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);

  }

}

0 Kudos

808 Views
Kan_Li
NXP TechSupport
NXP TechSupport

Hi Miguel,

I have reviewed your linker file, and I think  the definition for memory should be good, but the section definition, especially the content placed into code and code1 have some problem. I think you may do it in the following way:

.text :

  {

    * (.text)

    . = ALIGN(0x4);

  } > code

.text1 :               //<<<---------------------------------

  {

    * (.rodata)

    . = ALIGN(0x4);

    ___ROM_AT = .;

    ___DATA_ROM = .;

  } > code1

so that the texts are put in .text section and the rodata are placed in .text1 section.

Hope that helps,

B.R

Kan

0 Kudos

808 Views
night
Contributor II

Hi Kan,

I do it but it doesn't compile. Now it returns me overflow in code1:

"Overflow in segment: code1 from section: .text1 Segment reserved size is: 0x00004000 -- Overflow of: 0x00006ec4" 

I try to do the program code smaller, but doesn't works. The code size is always smaller than 270 KB.

Have you got any idea about it?

The memory configuration is correctly, I can see it in memory map and it is OK. I attached you the actual configuration with processor expert.

Very thanks again for your answer and for your help. It's important for me.

Best regards,

Miguel.

pastedImage_2.pngpastedImage_3.png

0 Kudos

808 Views
Kan_Li
NXP TechSupport
NXP TechSupport

Hi Miguel,

Seems the rodata section is larger than 16KB, so maybe you have to divide it into two parts, one placed in text, and the other placed in text1. I suggest using the following method to do that:

.text :

  {

    * (.text)

    . = ALIGN(0x4);

    main_c.obj (.rodata)  //the rodata belongs to main.c source file

  } > code

.text1 :               //<<<---------------------------------

  {

    * (.rodata)

    . = ALIGN(0x4);

    ___ROM_AT = .;

    ___DATA_ROM = .;

  } > code1

in the above example, I only put the rodata in main.c in .text section, and the rest are placed in .text1 section, you may move more from .text1 to .text according to your project .

Hope that helps,

B.R

Kan

0 Kudos

808 Views
night
Contributor II

Hi Kan,

     I did it, but it doesn't work. The error is the same!! In this case the compiler uses the second section and it need so much space (it tell me in the error report).

     Can you attach a complete example for K20 using this?

     It is very important for my application.

     Very Thanks. Best regards,

               Miguel Ángel

0 Kudos

808 Views
Kan_Li
NXP TechSupport
NXP TechSupport

Hi Miguel,

Would it be possible to send your project to me? I will try to figure out what the problem is.

Thanks and Best Regards,

Kan

0 Kudos

808 Views
nasreenshaikh
Contributor III

Yes you can use the 16Kb of extra memory. The linker file is to be changed as above. All you need to do then is place specific functions of your code in the new section. This can be done by using the  __attribute__ key word in front of the function declaration.

for example if you have a function as follows

void example(void)

{

}

then its declaration will be

__attribute__((section(".text1"))) void example(void);

where .text1 is the name of your new section you created in your linker file

0 Kudos