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
已解决! 转到解答。
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
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
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
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.
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
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
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