K20 P-Flash overflow detection

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

K20 P-Flash overflow detection

ソリューションへジャンプ
2,831件の閲覧回数
lategoodbye
Senior Contributor I

Hi,

 

i'm using K20DX256 (complete D-Flash for program code) and KDS (generated linker file) with the following memory configuration:

 

MEMORY {

  m_interrupts (RX) : ORIGIN = 0x00000000, LENGTH = 0x000001E0

  m_text      (RX) : ORIGIN = 0x00000410, LENGTH = 0x0003FBF0  // P-Flash

  m_text_10000000 (RX) : ORIGIN = 0x10000000, LENGTH = 0x00040000  // D-Flash

  m_data      (RW) : ORIGIN = 0x1FFF8000, LENGTH = 0x00008000

  m_data_20000000 (RW) : ORIGIN = 0x20000000, LENGTH = 0x00008000

  m_cfmprotrom  (RX) : ORIGIN = 0x00000400, LENGTH = 0x00000010

}

 

Since we need most of RAM and ROM we experienced an overflow of the initialized data beyond the P-Flash at 0x40000.

 

Here are my questions:

 

Is it possible to make the linker fail (special linker instruction) in case the initialized data goes beyond the P-Flash, but m_text and m_data boundaries are okay?

Original Attachment has been moved to: overflow.zip

ラベル(1)
0 件の賞賛
返信
1 解決策
2,444件の閲覧回数
Carlos_Musich
NXP Employee
NXP Employee

Hi Stefan,

there is something wrong with the linker. You can work around this by creating a dummy section at the en of the linker file and setting the pointer until the last address used. Please see below

  _romp_at = ___ROM_AT + SIZEOF(.data) +SIZEOF(.m_data_20000000);

  .romp : AT(_romp_at)

  {

    __S_romp = _romp_at;

    LONG(___ROM_AT);

    LONG(_sdata);

    LONG(___data_size);

    LONG(___m_data_20000000_ROMStart);

    LONG(___m_data_20000000_RAMStart);

    LONG(___m_data_20000000_ROMSize);

    LONG(0);

    LONG(0);

    LONG(0);

  } > m_data

 

 

   __CHECK_OVERFLOW = ___ROM_AT + SIZEOF(.data) + SIZEOF(.m_data_20000000) + SIZEOF(.romp);

  .dummy :

  {

    . = __CHECK_OVERFLOW;

 

  } > m_text

Regards,

Carlos

元の投稿で解決策を見る

0 件の賞賛
返信
8 返答(返信)
2,444件の閲覧回数
Alice_Yang
NXP TechSupport
NXP TechSupport

Hello  stefan,

If overflow, you can relocate some code to  FlexNVM, it also is you mentioned above  :m_text_10000000 (RX) ,

And about how to relocate , you can refer to here : Relocate Code (configuration linker files) - CW10.6 - Kinetis  there are some project create on CodeWarrior,

it is the same with KDS,

If it still have any question about this , please tell me the whole part number .

Hope it helps

Alice

0 件の賞賛
返信
2,444件の閲覧回数
lategoodbye
Senior Contributor I

Hello Alice,

thanks for your reply, but that is not the answer to my question. I know about relocation code to fix the issue.

Please let me clarify the intension of my question is: how can i detect all cases of overflow (e.g. ROMP reaches above P-Flash) during linking of the image?

I could write program to verify the MAP file about invalid addresses (address beyond 0x40000), but it would be nice to make the linker or KDS to inform me about the problem.

Best regards

Stefan

0 件の賞賛
返信
2,444件の閲覧回数
Carlos_Musich
NXP Employee
NXP Employee

Hello Stefan,

What you mean is that when you build the project you dont get an error if your application overflows the memory? If this is the case it is wrong, linker must display an error. Let me check it and I will be back to you ASAP.

0 件の賞賛
返信
2,444件の閲覧回数
lategoodbye
Senior Contributor I

Hi Carlos,

exactly. The linker doesn't give an error, because the boundaries of m_data and m_text are okay.

Here is the relevant extract of the MAP file:

COMMON 0x1fffa820 0x4 c:/freescale/kds_1.1.0/toolchain/bin/../lib/gcc/arm-none-eabi/4.8.0/../../../../arm-none-eabi/lib/m4\libg.a(lib_a-reent.o)
                0x1fffa820 errno
                0x1fffa824 . = ALIGN (0x4)
                0x1fffa824 __END_BSS = .
                0x1fffa824 PROVIDE (__bss_end__, __END_BSS)
                0x00040c48 _romp_at = ((___ROM_AT + SIZEOF (.data)) + SIZEOF (.m_data_20000000))

I marked the invalid address red.

What do you need for checking?

Stefan

0 件の賞賛
返信
2,444件の閲覧回数
Carlos_Musich
NXP Employee
NXP Employee

Hi Stefan,

I need to reproduce it. It would be very helpful if you share a project showing the failure. If you prefer you may submit a Service Request at www.freescale.com/support in case you dont want to share a project in community. Just ask for Carlos Musich.

Best regards,

Carlos

0 件の賞賛
返信
2,444件の閲覧回数
lategoodbye
Senior Contributor I

Hi Carlos,

i attached an example project in original post (build with KDS 1.1.0) to reproduce the problem.

Best regards

Stefan

0 件の賞賛
返信
2,445件の閲覧回数
Carlos_Musich
NXP Employee
NXP Employee

Hi Stefan,

there is something wrong with the linker. You can work around this by creating a dummy section at the en of the linker file and setting the pointer until the last address used. Please see below

  _romp_at = ___ROM_AT + SIZEOF(.data) +SIZEOF(.m_data_20000000);

  .romp : AT(_romp_at)

  {

    __S_romp = _romp_at;

    LONG(___ROM_AT);

    LONG(_sdata);

    LONG(___data_size);

    LONG(___m_data_20000000_ROMStart);

    LONG(___m_data_20000000_RAMStart);

    LONG(___m_data_20000000_ROMSize);

    LONG(0);

    LONG(0);

    LONG(0);

  } > m_data

 

 

   __CHECK_OVERFLOW = ___ROM_AT + SIZEOF(.data) + SIZEOF(.m_data_20000000) + SIZEOF(.romp);

  .dummy :

  {

    . = __CHECK_OVERFLOW;

 

  } > m_text

Regards,

Carlos

0 件の賞賛
返信
2,444件の閲覧回数
lategoodbye
Senior Contributor I

Thank you very much

0 件の賞賛
返信