Splitting m_text in Linker File of CW

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

Splitting m_text in Linker File of CW

1,137 Views
vigneshbalaji
Senior Contributor I

Hi,

    I am not able to understand the listing 10 in the document.Based on what are they calculating the origin address when 0x1000 is removed from existing m_text to form a new text. I want to know how they found out the origin address of my_text????

 

This is the thing given in the document.

 

 

Now we need to edit linker file (.ld) to create a new segment where this function is going to be relocated. Compare listing 10 with listing 1 and notice that 0x1000 bytes were subtracted from segment ‘m_text’ to create segment ‘my_text’.

 

MEMORY { 

m_interrupts (rx) : ORIGIN = 0x00000000, LENGTH = 0x1E8 

m_cfmprotrom (rx) : ORIGIN = 0x00000400, LENGTH = 0x10 

m_text  (rx) : ORIGIN = 0x00000800, LENGTH = 0x1M - 0x1800 

my_text  (rx) : ORIGIN = 0x000FF000, LENGTH = 0x1000  /* New ROM Segment */ 

m_data  (rwx) : ORIGIN = 0x1FFF0000, LENGTH = 64K   

m_data2 (rwx) : ORIGIN = 0x20000000, LENGTH = 64K 

}

 

I have also attached the document.

Labels (1)
7 Replies

774 Views
TICS_Fiona
NXP Employee
NXP Employee

Hello Vignesh

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

In list10,  The ‘m_text‘ is from 0x00000800 to 0x000FEFFF. The ‘my_text‘ is from 0x000FF000 to 0X000FFFFF

m_text (rx) : ORIGIN = 0x00000800, LENGTH = 0x1M - 0x1800

my_text (rx) : ORIGIN = 0x000FF000, LENGTH = 0x1000

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

In list 1, the ‘m_text‘ is from 0x00000800 to 0x000FFFFF.

m_text (rx) : ORIGIN = 0x00000800, LENGTH = 1M - 0x800

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

You are correct that compared with list 1, the size of  ‘m_text’ is 0x1000 bytes less.  This memory area is relocated for another section ‘.my_text’.  That is how to relocate code that the author intent to show us.  The list 10 shows how to allocate a function at a fixed address, which is 0x000FF000 in this example.

Best Regards

Fiona Kuang

TIC - Technical Information Center

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

Note: If this post answers your question, please click the Mark Correct button. Thank you!

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

774 Views
vigneshbalaji
Senior Contributor I

Hi Jin,

    I have splitted the text segment in KEA-128.I want to know whether it is right or not.Please Look at my project I have attached it.

This is my text division.Please take a look at it and tell me whether I have divided it right or not as per KEA-128.I am confused about the start address of my_text.Is it right???

MEMORY

{

  m_interrupts (rx) : ORIGIN = 0x00000000, LENGTH = 0xC0

  m_cfmprotrom  (rx) : ORIGIN = 0x00000400, LENGTH = 0x10

  m_text  (rx) : ORIGIN = 0x00000800, LENGTH = 128K - 0x800

  my_text      (rx) : ORIGIN = 0x0001EC00, LENGTH = 0x1000              /*New ROM segment*/

  m_data    (rwx) : ORIGIN = 0x1FFFF000, LENGTH = 16K /* SRAM */

}

0 Kudos

774 Views
TICS_Fiona
NXP Employee
NXP Employee

Hello Vignesh

In your code, 128K is in decimal format. So the section ‘ m_text ’ is from 0x00000800 to 0x0001FFFF.  

According to the memory map for KEAZ128, its flash address is from 0x0000_0000 to 0x0001FFFF.

So there is no flash memory left for ‘my_text’. Please reduce the size of  ‘ m_text ’, so that there could be still memory space  left for ‘my_text’.

Best Regards

Fiona Kuang

TIC - Technical Information Center

774 Views
vigneshbalaji
Senior Contributor I

Hi Fiona,

So 128K is 128000 in decimal.

So 128000(0x1F400) - 0x800 = 0x1EC00 (length of my_text)

So 0x1EC00 is the length.so the start or origin address of my_text should be

0x1EC00(length of m_text) + 0x800(start address of m_text) = 0x1F400.

So,I think  0x1F400 is the starting address of  my_text.

If not please explain me with the calculations.

0 Kudos

774 Views
TICS_Fiona
NXP Employee
NXP Employee

Hello Vignesh

128K is 131072 in decimal, 128*1024,  which is 0x20000 in hex.

Best Regards

Fiona Kuang

TIC - Technical Information Center

0 Kudos

774 Views
vigneshbalaji
Senior Contributor I

Hi,

    I want you to show the calculations.I can understand 0x1000 is getting subtracted.

My questions are:-

1)whether it is 0x1M or 1M. Since in your answerr at one place you have used 0x1M and at other you have used 1M???

2)what is the decimal value of 0x1M??

3)Please show me How we got the origin address of my_text??? After adding the m_text origin address plus length?? Please show me the calculations?

0 Kudos

774 Views
TICS_Fiona
NXP Employee
NXP Employee

Hello Vignesh

You found the problem.

In list10, the ‘m_text‘ is from 0x00000800 to 0x000FEFFF. The ‘my_text‘ is  from 0x000FF000 to 0X000FFFFF.

The length of m_text (rx) should be (1M - 0x1800). 1M is in the decimal value. So it should be:

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

m_text (rx) : ORIGIN = 0x00000800, LENGTH = 1M - 0x1800

my_text (rx) : ORIGIN = 0x000FF000, LENGTH = 0x1000

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

Best Regards

Fiona Kuang

TIC - Technical Information Center

0 Kudos