How to add code files in sections of Flash?

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

How to add code files in sections of Flash?

Jump to solution
2,190 Views
anishvenkataram
Contributor II

Hi,

I am using MCUXpresso IDE for a project(MK22FN512xx) where I need to link code files in a specific section of the flash. I would really appreciate if someone could point me in the direction of where to look for it or even a step by step guide. I have tried adding a section in the flash(NON_SAFETY) via mcu settings and then in the input linker section i added a simple heartbeat.o file. Image belowpastedImage_1.png

After this when I debug and see the map file, I can see the file is mapped to address I specified but the % usage looks way off the charts. pastedImage_2.png

pastedImage_3.png

Any help is appreciated. Thanks in advance.

-Anish

#mcuxpressoide#linker file#manage linker script#k22fn512

Labels (1)
1 Solution
1,916 Views
FelipeGarcia
NXP Employee
NXP Employee

Hi Anish,

 

Please try the following in order to relocate a library in MCUXpresso.

 

First you need to be able to modify linker script.

pastedImage_2.png

Then you add the following to the linker script.

   

.text : ALIGN(8)

    {

       *(EXCLUDE_FILE(*library.o) .text*)

       *(EXCLUDE_FILE(*library.o) .rodata)

       *(EXCLUDE_FILE(*library.o).rodata.*)

       *(EXCLUDE_FILE(*library.o).constdata)

       *(EXCLUDE_FILE(*library.o).constdata.*)

       . = ALIGN(8);

    } > PROGRAM_FLASH

   

.text_Flash2 : ALIGN(8)

    {

       *library.o(.text*)

       *library.o(.rodata .rodata.* .constdata .constdata.*)

       . = ALIGN(8);

    } > PROGRAM_FLASH_512‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍

 

I hope this helps.

 

Best regards,

Felipe

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

- We are following threads for 7 weeks after the last post, later replies are ignored
Please open a new thread and refer to the closed one, if you have a related question at a later point in time.
-------------------------------------------------------------------------------

View solution in original post

6 Replies
1,916 Views
ErichStyger
Senior Contributor V

See the IDE user manual:

pastedImage_1.png

1,916 Views
anishvenkataram
Contributor II

Hello Erich,

 

First of all, I would like to thank you for the data you post on your website. Your website came to my rescue yet again. I read your post on "Putting Code of Files into Special Section with the GNU Linker" for KDS. I tried it and it gave me a lot of confidence and I was able to replicate the same procedure on MCUXpresso. It works perfectly now. 

Once again thank you for helping many embedded engineers all around the world.

Stay Safe and Healthy,

Best Regards,

Anish

1,916 Views
ErichStyger
Senior Contributor V

Hi Anish,

thank you :-).

On top of that: There is as well a way using FreeMarker scripts so usually you don't need to disable the managed linker file. I think this should work for you case too.

A similar use case is described in Linking Bootloader Applications with Eclipse and FreeMarker Scripts | MCU on Eclipse 

I hope this helps too,

Erich

1,916 Views
anishvenkataram
Contributor II

Hi Erich,

Thanks! That was the first thing I needed to do, allocate space for the bootloader. I will check out FreeMarker, if it saves me time and effort. I would say your reply was a bit of a fan moment for me. :smileyhappy:

Best Regards,

Anish

0 Kudos
1,917 Views
FelipeGarcia
NXP Employee
NXP Employee

Hi Anish,

 

Please try the following in order to relocate a library in MCUXpresso.

 

First you need to be able to modify linker script.

pastedImage_2.png

Then you add the following to the linker script.

   

.text : ALIGN(8)

    {

       *(EXCLUDE_FILE(*library.o) .text*)

       *(EXCLUDE_FILE(*library.o) .rodata)

       *(EXCLUDE_FILE(*library.o).rodata.*)

       *(EXCLUDE_FILE(*library.o).constdata)

       *(EXCLUDE_FILE(*library.o).constdata.*)

       . = ALIGN(8);

    } > PROGRAM_FLASH

   

.text_Flash2 : ALIGN(8)

    {

       *library.o(.text*)

       *library.o(.rodata .rodata.* .constdata .constdata.*)

       . = ALIGN(8);

    } > PROGRAM_FLASH_512‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍

 

I hope this helps.

 

Best regards,

Felipe

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

- We are following threads for 7 weeks after the last post, later replies are ignored
Please open a new thread and refer to the closed one, if you have a related question at a later point in time.
-------------------------------------------------------------------------------

1,916 Views
anishvenkataram
Contributor II

Hi Felipe Garcia,

Thank you for your response. I was able to able to resolve the issue by the same method a few days back. I appreciate your response.

I was hoping the GUI would do it for me rather than me editing the linker script.  That would make life much simpler.  

Once again thank you,

Stay safe and healthy,

Best Regards,

Anish

0 Kudos