How to locate third party libraries in external flash

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

How to locate third party libraries in external flash

Jump to solution
1,301 Views
deniscollis
Contributor V

I have a large third party library (example: libTLV.a) currently located and running on the K8x's Internal Flash.  I do not have any source code, just a header file (example: libTLV.h) and the library archive containing a number of .o objects.

Within MCUXpresso, how do I locate it on external QSPI XiP flash?

(Note1: I can locate my own code easily enough using the __TEXT macro after including cr_section_macros.h)

(Note2: I know how to locate .o objects in a specific memory section using a standard gcc linker script, but I would like to know how to do this in MCUXpresso)

Labels (1)
0 Kudos
1 Solution
1,082 Views
BlackNight
NXP Employee
NXP Employee

Hi Denis,

in the linker file, you can put code sections of specific files into dedicated memory ranges. An example for object files is described in Putting Code of Files into Special Section with the GNU Linker | MCU on Eclipse, but it should work the same for your library too. I would check the linker map file to see what names it is using.

I hope this helps,

Erich

View solution in original post

4 Replies
1,082 Views
deniscollis
Contributor V

Revisiting this...  How to locate entire library archives in specific a memory section, here are example excerpts from the .ld scripts.  

-------- snip --------

MEMORY
{
  /* Define each memory region */
  PROGRAM_FLASH (rx) : ORIGIN = 0x00000000, LENGTH = 0x40000 /* 256K bytes (alias Flash)  */
  SRAM_LOWER   (rwx) : ORIGIN = 0x1fff0000, LENGTH = 0x10000 /*  64K bytes (alias RAM2)   */
  SRAM_UPPER   (rwx) : ORIGIN = 0x20000000, LENGTH = 0x30000 /* 192K bytes (alias RAM)    */
  EXT_PGM_FLASH (rx) : ORIGIN = 0x68000000, LENGTH = 0x80000 /* 512K bytes (alias Flash2) */
}

-------- snip --------‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍

-------- snip --------

SECTIONS
{
   /* EXTERNAL QSPI XiP FLASH */
   .text_Flash2 : ALIGN(4)
   {
       FILL(0xff)
       *(.text_Flash2*)
       *(.text_EXT_PGM_FLASH*)
       *(.text.$Flash2*)
       *(.text.$EXT_PGM_FLASH*)
       *(.rodata.$Flash2*)
       *(.rodata.$EXT_PGM_FLASH*)
 
       /* Place lib archives in external flash */ 
       *libTLV.a:*  
   } > EXT_PGM_FLASH

/* MAIN TEXT SECTION */
   .text : ALIGN(4)
   {
       FILL(0xff)‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍

-------- snip --------‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍
0 Kudos
1,083 Views
BlackNight
NXP Employee
NXP Employee

Hi Denis,

in the linker file, you can put code sections of specific files into dedicated memory ranges. An example for object files is described in Putting Code of Files into Special Section with the GNU Linker | MCU on Eclipse, but it should work the same for your library too. I would check the linker map file to see what names it is using.

I hope this helps,

Erich

1,082 Views
deniscollis
Contributor V

Hi Erich,

I thought there may be something more automatic already built into MCUXpresso, but sadly, not.   Looks like I need to fix it for the old-school way:

  1. Use Freemarker to generate .ld files from .ldt templates  (edit: Not necessary, this is automatically done by MCUXpresso - see reply below)
  2. Disable managed linker scrips in MCUXpresso
  3. Edit the .ld files as required

 

Thanks for your help,

Denis

0 Kudos
1,082 Views
deniscollis
Contributor V

Just noticed that the .ld files are already created by MCUXpresso.  One simply needs to copy them from the build configuration output folder (e.g. Debug/MyProject_Debug*.ld) to the the startup/ folder, and then in project Properties -> C/C++ Build -> Settings -> Tool Settings -> Managed Linker Script  -- uncheck 'Manage linker script' and enter the 'Linker script' name, (e.g. 'MyProject.ld')  and the  'Script path' (e.g. '../startup/').

0 Kudos