<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>LPCXpresso IDE中的主题 use specific memory section memory to link a variable</title>
    <link>https://community.nxp.com/t5/LPCXpresso-IDE/use-specific-memory-section-memory-to-link-a-variable/m-p/1414407#M33324</link>
    <description>&lt;P&gt;I'm having trouble in setting the section attribute of gcc to define that a variable should reside in a specific memory section instead of the default.&lt;/P&gt;&lt;P&gt;I'm using the arm cortex m3 LPC1759. I got the link files from LPCXpresso IDE, but I don't use it, I have my own makefile. The link files are:&lt;/P&gt;&lt;H3&gt;Generic link file&lt;/H3&gt;&lt;LI-CODE lang="markup"&gt;INCLUDE "./link/LPCmem.ld" /* see below */

ENTRY(ResetISR)

SECTIONS
{
    /* MAIN TEXT SECTION */    
    .text : ALIGN(4)
    {
        FILL(0xff)
        __vectors_start__ = ABSOLUTE(.) ;
        KEEP(*(.isr_vector))
        
        /* Global Section Table */
        . = ALIGN(4) ;
        __section_table_start = .;
        __data_section_table = .;
        LONG(LOADADDR(.data));
        LONG(    ADDR(.data));
        LONG(  SIZEOF(.data));
        LONG(LOADADDR(.data_RAM2));
        LONG(    ADDR(.data_RAM2));
        LONG(  SIZEOF(.data_RAM2));
        __data_section_table_end = .;
        __bss_section_table = .;
        LONG(    ADDR(.bss));
        LONG(  SIZEOF(.bss));
        LONG(    ADDR(.bss_RAM2));
        LONG(  SIZEOF(.bss_RAM2));
        __bss_section_table_end = .;
        __section_table_end = . ;
        /* End of Global Section Table */
        

        *(.after_vectors*)
    } &amp;gt;FLASH
    
    .text : ALIGN(4)    
    {
         *(.text*)
        *(.rodata .rodata.* .constdata .constdata.*)
        . = ALIGN(4);
        
    } &amp;gt; FLASH

    /*
     * for exception handling/unwind - some Newlib functions (in common
     * with C++ and STDC++) use this. 
     */
    .ARM.extab : ALIGN(4)
    {
        *(.ARM.extab* .gnu.linkonce.armextab.*)
    } &amp;gt; FLASH
    __exidx_start = .;
    
    .ARM.exidx : ALIGN(4)
    {
        *(.ARM.exidx* .gnu.linkonce.armexidx.*)
    } &amp;gt; FLASH
    __exidx_end = .;
    
    _etext = .;
    
    /* DATA section for SRAM0 */
    .data_RAM2 : ALIGN(4)
    {
       FILL(0xff)
       *(.ramfunc.$RAM2)
       *(.ramfunc.$SRAM0)
        *(.data.$RAM2*)
        *(.data.$SRAM0*)
       . = ALIGN(4) ;
    } &amp;gt; SRAM0 AT&amp;gt;FLASH
    
    /* MAIN DATA SECTION */
    .uninit_RESERVED : ALIGN(4)
    {
        KEEP(*(.bss.$RESERVED*))
        . = ALIGN(4) ;
        _end_uninit_RESERVED = .;
    } &amp;gt; SRAM
    
    /* Main DATA section (SRAM) */
    .data : ALIGN(4)
    {
       FILL(0xff)
       _data = . ;
       *(vtable)
       *(.ramfunc*)
       *(.data*)
       . = ALIGN(4) ;
       _edata = . ;
    } &amp;gt; SRAM AT&amp;gt;FLASH

    /* BSS section for SRAM0 */
    .bss_RAM2 : ALIGN(4)
    {
        *(.bss.$RAM2*)
        *(.bss.$SRAM0*)
       . = ALIGN(4) ;
    } &amp;gt; SRAM0

    /* MAIN BSS SECTION */
    .bss : ALIGN(4)
    {
        _bss = .;
        *(.bss*)
        *(COMMON)
        . = ALIGN(4) ;
        _ebss = .;
        PROVIDE(end = .);
    } &amp;gt; SRAM
        
    /* NOINIT section for SRAM0 */
    .noinit_RAM2 (NOLOAD) : ALIGN(4)
    {
        *(.noinit.$RAM2*)
        *(.noinit.$SRAM0*)
       . = ALIGN(4) ;
    } &amp;gt; SRAM0 
    
    /* DEFAULT NOINIT SECTION */
    .noinit (NOLOAD): ALIGN(4)
    {
        _noinit = .;
        *(.noinit*) 
         . = ALIGN(4) ;
        _end_noinit = .;
    } &amp;gt; SRAM
        
    PROVIDE(_pvHeapStart = .);
    PROVIDE(_vStackTop = __top_SRAM - 0);
}&lt;/LI-CODE&gt;&lt;H3&gt;Memory definition file&lt;/H3&gt;&lt;LI-CODE lang="markup"&gt;/* Define each memory region */
MEMORY
{
  FLASH (rx) : ORIGIN = 0x0, LENGTH = 0x80000           /* 512K bytes */
  SRAM (rwx) : ORIGIN = 0x10000000, LENGTH = 0x8000     /* 32K bytes */
  SRAM0 (rwx) : ORIGIN = 0x2007c000, LENGTH = 0x8000    /* 32K bytes */
}

/* Define a symbol for the top of each memory region */
__top_FLASH = 0x0 + 0x80000;
__top_SRAM = 0x10000000 + 0x8000;
__top_SRAM0 = 0x2007c000 + 0x8000;&lt;/LI-CODE&gt;&lt;P&gt;Above is the&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;EM&gt;LPCmem.ld&lt;/EM&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;file included in the previous file.&lt;/P&gt;&lt;P&gt;I'm forcing the freertos heap variable to be in the custom section, like this:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;static unsigned char ucHeap[ configTOTAL_HEAP_SIZE ]
        __attribute__((section(".data_RAM2")));&lt;/LI-CODE&gt;&lt;P&gt;&lt;SPAN&gt;The linking of objects files are done without errors, but the variable isn't placed in the right memory position, how I could check with nm command:&lt;/SPAN&gt;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;...
10000028 d ucHeap
10002028 d uxCriticalNesting
...&lt;/LI-CODE&gt;&lt;P&gt;&lt;SPAN&gt;I try to change the section to another that doesn't exist, just to check if the linker verifies the names, and apparently, it doesn't.&lt;/SPAN&gt;&lt;/P&gt;</description>
    <pubDate>Wed, 16 Feb 2022 11:28:19 GMT</pubDate>
    <dc:creator>Candice1</dc:creator>
    <dc:date>2022-02-16T11:28:19Z</dc:date>
    <item>
      <title>use specific memory section memory to link a variable</title>
      <link>https://community.nxp.com/t5/LPCXpresso-IDE/use-specific-memory-section-memory-to-link-a-variable/m-p/1414407#M33324</link>
      <description>&lt;P&gt;I'm having trouble in setting the section attribute of gcc to define that a variable should reside in a specific memory section instead of the default.&lt;/P&gt;&lt;P&gt;I'm using the arm cortex m3 LPC1759. I got the link files from LPCXpresso IDE, but I don't use it, I have my own makefile. The link files are:&lt;/P&gt;&lt;H3&gt;Generic link file&lt;/H3&gt;&lt;LI-CODE lang="markup"&gt;INCLUDE "./link/LPCmem.ld" /* see below */

ENTRY(ResetISR)

SECTIONS
{
    /* MAIN TEXT SECTION */    
    .text : ALIGN(4)
    {
        FILL(0xff)
        __vectors_start__ = ABSOLUTE(.) ;
        KEEP(*(.isr_vector))
        
        /* Global Section Table */
        . = ALIGN(4) ;
        __section_table_start = .;
        __data_section_table = .;
        LONG(LOADADDR(.data));
        LONG(    ADDR(.data));
        LONG(  SIZEOF(.data));
        LONG(LOADADDR(.data_RAM2));
        LONG(    ADDR(.data_RAM2));
        LONG(  SIZEOF(.data_RAM2));
        __data_section_table_end = .;
        __bss_section_table = .;
        LONG(    ADDR(.bss));
        LONG(  SIZEOF(.bss));
        LONG(    ADDR(.bss_RAM2));
        LONG(  SIZEOF(.bss_RAM2));
        __bss_section_table_end = .;
        __section_table_end = . ;
        /* End of Global Section Table */
        

        *(.after_vectors*)
    } &amp;gt;FLASH
    
    .text : ALIGN(4)    
    {
         *(.text*)
        *(.rodata .rodata.* .constdata .constdata.*)
        . = ALIGN(4);
        
    } &amp;gt; FLASH

    /*
     * for exception handling/unwind - some Newlib functions (in common
     * with C++ and STDC++) use this. 
     */
    .ARM.extab : ALIGN(4)
    {
        *(.ARM.extab* .gnu.linkonce.armextab.*)
    } &amp;gt; FLASH
    __exidx_start = .;
    
    .ARM.exidx : ALIGN(4)
    {
        *(.ARM.exidx* .gnu.linkonce.armexidx.*)
    } &amp;gt; FLASH
    __exidx_end = .;
    
    _etext = .;
    
    /* DATA section for SRAM0 */
    .data_RAM2 : ALIGN(4)
    {
       FILL(0xff)
       *(.ramfunc.$RAM2)
       *(.ramfunc.$SRAM0)
        *(.data.$RAM2*)
        *(.data.$SRAM0*)
       . = ALIGN(4) ;
    } &amp;gt; SRAM0 AT&amp;gt;FLASH
    
    /* MAIN DATA SECTION */
    .uninit_RESERVED : ALIGN(4)
    {
        KEEP(*(.bss.$RESERVED*))
        . = ALIGN(4) ;
        _end_uninit_RESERVED = .;
    } &amp;gt; SRAM
    
    /* Main DATA section (SRAM) */
    .data : ALIGN(4)
    {
       FILL(0xff)
       _data = . ;
       *(vtable)
       *(.ramfunc*)
       *(.data*)
       . = ALIGN(4) ;
       _edata = . ;
    } &amp;gt; SRAM AT&amp;gt;FLASH

    /* BSS section for SRAM0 */
    .bss_RAM2 : ALIGN(4)
    {
        *(.bss.$RAM2*)
        *(.bss.$SRAM0*)
       . = ALIGN(4) ;
    } &amp;gt; SRAM0

    /* MAIN BSS SECTION */
    .bss : ALIGN(4)
    {
        _bss = .;
        *(.bss*)
        *(COMMON)
        . = ALIGN(4) ;
        _ebss = .;
        PROVIDE(end = .);
    } &amp;gt; SRAM
        
    /* NOINIT section for SRAM0 */
    .noinit_RAM2 (NOLOAD) : ALIGN(4)
    {
        *(.noinit.$RAM2*)
        *(.noinit.$SRAM0*)
       . = ALIGN(4) ;
    } &amp;gt; SRAM0 
    
    /* DEFAULT NOINIT SECTION */
    .noinit (NOLOAD): ALIGN(4)
    {
        _noinit = .;
        *(.noinit*) 
         . = ALIGN(4) ;
        _end_noinit = .;
    } &amp;gt; SRAM
        
    PROVIDE(_pvHeapStart = .);
    PROVIDE(_vStackTop = __top_SRAM - 0);
}&lt;/LI-CODE&gt;&lt;H3&gt;Memory definition file&lt;/H3&gt;&lt;LI-CODE lang="markup"&gt;/* Define each memory region */
MEMORY
{
  FLASH (rx) : ORIGIN = 0x0, LENGTH = 0x80000           /* 512K bytes */
  SRAM (rwx) : ORIGIN = 0x10000000, LENGTH = 0x8000     /* 32K bytes */
  SRAM0 (rwx) : ORIGIN = 0x2007c000, LENGTH = 0x8000    /* 32K bytes */
}

/* Define a symbol for the top of each memory region */
__top_FLASH = 0x0 + 0x80000;
__top_SRAM = 0x10000000 + 0x8000;
__top_SRAM0 = 0x2007c000 + 0x8000;&lt;/LI-CODE&gt;&lt;P&gt;Above is the&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;EM&gt;LPCmem.ld&lt;/EM&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;file included in the previous file.&lt;/P&gt;&lt;P&gt;I'm forcing the freertos heap variable to be in the custom section, like this:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;static unsigned char ucHeap[ configTOTAL_HEAP_SIZE ]
        __attribute__((section(".data_RAM2")));&lt;/LI-CODE&gt;&lt;P&gt;&lt;SPAN&gt;The linking of objects files are done without errors, but the variable isn't placed in the right memory position, how I could check with nm command:&lt;/SPAN&gt;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;...
10000028 d ucHeap
10002028 d uxCriticalNesting
...&lt;/LI-CODE&gt;&lt;P&gt;&lt;SPAN&gt;I try to change the section to another that doesn't exist, just to check if the linker verifies the names, and apparently, it doesn't.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 16 Feb 2022 11:28:19 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPCXpresso-IDE/use-specific-memory-section-memory-to-link-a-variable/m-p/1414407#M33324</guid>
      <dc:creator>Candice1</dc:creator>
      <dc:date>2022-02-16T11:28:19Z</dc:date>
    </item>
    <item>
      <title>Re: use specific memory section memory to link a variable</title>
      <link>https://community.nxp.com/t5/LPCXpresso-IDE/use-specific-memory-section-memory-to-link-a-variable/m-p/1415855#M33325</link>
      <description>&lt;P&gt;Hi&amp;nbsp;Candice1&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Please check if this article can help you&lt;/P&gt;
&lt;P&gt;&lt;A href="https://community.nxp.com/t5/LPC-Microcontrollers-Knowledge/LPC-How-to-place-data-function-file-in-specified-memory-under/ta-p/1316392" target="_blank"&gt;https://community.nxp.com/t5/LPC-Microcontrollers-Knowledge/LPC-How-to-place-data-function-file-in-specified-memory-under/ta-p/1316392&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;Have a nice day&lt;/P&gt;
&lt;P&gt;Jun Zhang&lt;/P&gt;</description>
      <pubDate>Fri, 18 Feb 2022 07:58:59 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPCXpresso-IDE/use-specific-memory-section-memory-to-link-a-variable/m-p/1415855#M33325</guid>
      <dc:creator>ZhangJennie</dc:creator>
      <dc:date>2022-02-18T07:58:59Z</dc:date>
    </item>
  </channel>
</rss>

