CWS porting to KDS - Linker definitions

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

CWS porting to KDS - Linker definitions

Jump to solution
1,497 Views
yaronlederman
Contributor II

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

Labels (1)
0 Kudos
Reply
1 Solution
1,196 Views
Alice_Yang
NXP TechSupport
NXP TechSupport

Hello Yaron,

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

  do you want to relocate the long_call intot he section of ".relocate_code" , if yes, there is a DOC aobut

how to relocate using KDS :

Relocating Code and Data Using the KDS GCC Linker File for Kinetis

2. About the problem and error, could you please take a screenshot to me ,  or i don't know what's

the detail problem about your project .

3.And i also recommend you ""create  a new KDS project and add (slowly but surely) my older code which I did." , only copy the

application code , the other system files use the KDS generate .

Hope it helps

Alice

View solution in original post

0 Kudos
Reply
5 Replies
1,196 Views
alubeiro
Contributor IV

Hi again,

After knowing how to preserve memory zones, i have tried to load both aplications the boot and the user app programs into flash.

i have changed the address of the entry point so now the boot jumps to the line 330 of the user´s app startup and for my surprise the user app is running successfully

pastedImage_4.png

What is the difference of jumping to this entry point in the user app and jumping to the same entry point but in its own app (boot)??

Why is the boot gettiing stuck in that interrupt???

Thanks and best regards

0 Kudos
Reply
1,196 Views
alubeiro
Contributor IV

Hi Alice,

I was refering to other thing but thanks for your response.

so far I have made any progress but still cant achieve what i want to do.

I want to jump to the startup so the program starts again. Later i will use it to jump to the user aplicaton from the boot by changing the address. Im just want to check that the jump is made correctly.

I have already done this a couple of years ago with CW and K60 successfully so i have created a quick project in CW with the K22 in order to see if i can make it work there.

In this case (in compare with KDS) the startup is a function into a .c file so i have made the same i did before with K60. This is

1- Create a new segment

pastedImage_1.png

2- Create a new section into this new segment

pastedImage_2.png

3- Alocate the startup function into this section

pastedImage_11.png

Look at the .map file (the startup is correctly placed at 0x410)

pastedImage_3.png

4- Make the jump to the address where the startup is located.

pastedImage_4.png

But when the program executes the jump it gets stuck in.....

pastedImage_5.png

What am i doing wrong????

In KDS i make the same with the diference that the startup is not a function into a .c file but a .s file, and the code is placed at the begining of m_text segment so i make the jump to the address where the line 331 is executed. But here the program gets stuck in a DefaultISR

pastedImage_12.png

Thanks and best regards

0 Kudos
Reply
1,197 Views
Alice_Yang
NXP TechSupport
NXP TechSupport

Hello Yaron,

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

  do you want to relocate the long_call intot he section of ".relocate_code" , if yes, there is a DOC aobut

how to relocate using KDS :

Relocating Code and Data Using the KDS GCC Linker File for Kinetis

2. About the problem and error, could you please take a screenshot to me ,  or i don't know what's

the detail problem about your project .

3.And i also recommend you ""create  a new KDS project and add (slowly but surely) my older code which I did." , only copy the

application code , the other system files use the KDS generate .

Hope it helps

Alice

0 Kudos
Reply
1,196 Views
alubeiro
Contributor IV

Hi Alice,

Thanks for the info but i have a doubt.

In my case i want to relocate the sturtup code and it is not a function. It is a .s file, so how can i relocate it???

I´m working with K22 and KDS.

Please find attached the file.

Thanks and best regards

0 Kudos
Reply
1,196 Views
Alice_Yang
NXP TechSupport
NXP TechSupport

Hello Alberto,

I attached a project , it relocate all the code to 0x1000 through configure

the linker file ,  does it can satisfy your demand ?pastedImage_1.png

Hope it helps

Alice

0 Kudos
Reply