AnsweredAssumed Answered

CWS porting to KDS - Linker definitions

Question asked by Yaron Lederman on Feb 21, 2016

Hi,

 

My mission was to port my code-limited CWS 10.2 project to KDS 3.x - with my MK60FN1M0VMD device

After reviewing multiple articles and recommendations, I followed the suggestion to create  a new KDS project and add (slowly but surely) my older code which I did.

Eventually my code compiled !

Major issue worth mentioning:

1. Due to errata e2448 k60 - my code included the workaround requiring the relocate code macro - which relocates code to RAM - the macro didn't compile in KDS

I found an article which describes a similar issue suggestion the following replace:

//#define __relocate_code__   __declspec(relocate_code)                    <-- CWS 10.2

#define __relocate_code__ __attribute__((section(".relocate_code"), long_call))

and it compiled - works - see below

 

2. asm command- depends on toolchain and optimization - I followed Erich Styger recommendation (in one of the many articles I read) and stayed with ISO99 and renamed to __asm.

 

3. The new k60xx header from KDS didn't compile / required different definitions - as I didn't want to change my project I used the old CWS k60xx file (My project worked after all !) and added the required definitions where requied

 

4. Startup and Updating the linker file

This is my current problem:

Initially I tried to replace the KDS init section simply as is with the CWS ones - it did either not compile or didn't work

My second approach was to take the init sections proivded with the KDS new project and try to adopt them to my WORKING project

 

So I took from the old kinetis_sysinit.* all the code which initialized my board and adopted the linker section as follows:

I used the same memory section names provided by the KDS since I assumed the assembly startup code and other unknown portions would make use of those specific names

 

 

OLD CWS:

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

MEMORY {

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

m_text        (RX) : ORIGIN = 0x00000800, LENGTH = 0x00100000-0x00000800

m_data        (RW) : ORIGIN = 0x1FFF0000, LENGTH = 0x00020000

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

}

 

NEW KDS:

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

/* Specify the memory areas */

MEMORY

{

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

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

  m_flash_config        (RX)  : ORIGIN = 0x00000400, LENGTH = 0x00000010 /* replaced m_cfmprotrom */

  m_text        (RX) : ORIGIN = 0x00000440, LENGTH = 0x000F0000-0x00000440

/*  m_text                (RX)  : ORIGIN = 0x00000410, LENGTH = 0x000FFBF0

  m_data                (RW)  : ORIGIN = 0x20000000, LENGTH = 0x00010000 YL */ 

  m_data         (RW) : ORIGIN = 0x1FFF0000, LENGTH = 0x00020000

/*  m_data_1FFF0000       (RW)  : ORIGIN = 0x1FFF0000, LENGTH = 0x00010000*/

}

 

Section SIZES and RANGED have been adopted according to my old CWS sections parameters

 

Files are enclosed

 

When loading the new compiled ELF file - nothing works..

Any help will be greatly appreciated

 

regards,

Yaron

Original Attachment has been moved to: MK60N512VMD100_flash.lcf.zip

Original Attachment has been moved to: MK60FN1M0xxx12_flash.ld.zip

Outcomes