<?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>topic LPC55S69: USB SRAM usage in ROM in LPC Microcontrollers</title>
    <link>https://community.nxp.com/t5/LPC-Microcontrollers/LPC55S69-USB-SRAM-usage-in-ROM/m-p/991934#M39050</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi !&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="color: #51626f; background-color: #ffffff; border: 0px; font-size: 14px;"&gt;I try to see if USB_SRAM at ox50100000 can be used for keep some data over reboot.&lt;/P&gt;&lt;P style="color: #51626f; background-color: #ffffff; border: 0px; font-size: 14px;"&gt;And it seems to me it is wiped by 0x00 by ROM code every reboot even ISP USB flashing is not used.&lt;/P&gt;&lt;P style="color: #51626f; background-color: #ffffff; border: 0px; font-size: 14px;"&gt;SRAM4 area at 0x30040000 is keep data over reboot for example.&lt;/P&gt;&lt;P style="color: #51626f; background-color: #ffffff; border: 0px; font-size: 14px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P style="color: #51626f; background-color: #ffffff; border: 0px; font-size: 14px;"&gt;Could you look in what cases USB_RAM wiped ? All the time over reboot or in some cases.&lt;/P&gt;&lt;P style="color: #51626f; background-color: #ffffff; border: 0px; font-size: 14px;"&gt;Can it be disabled some how in any setting if USB ISP flashing is&amp;nbsp; not planned to be used at all ?&lt;/P&gt;&lt;P style="color: #51626f; background-color: #ffffff; border: 0px; font-size: 14px;"&gt;My application need a lot of SRAM and USB_SRAM need as well.&lt;/P&gt;&lt;P style="color: #51626f; background-color: #ffffff; border: 0px; font-size: 14px;"&gt;&lt;/P&gt;&lt;P style="color: #51626f; background-color: #ffffff; border: 0px; font-size: 14px;"&gt;USB_SRAM is not mentioned in any Linked files and regular firmware is not counted it as bss are and not zeroed it for sure.&lt;/P&gt;&lt;P style="color: #51626f; background-color: #ffffff; border: 0px; font-size: 14px;"&gt;&lt;/P&gt;&lt;P style="color: #51626f; background-color: #ffffff; border: 0px; font-size: 14px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P style="color: #51626f; background-color: #ffffff; border: 0px; font-size: 14px;"&gt;Regards,&lt;/P&gt;&lt;P style="color: #51626f; background-color: #ffffff; border: 0px; font-size: 14px;"&gt;Eugene&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 06 Feb 2020 07:52:30 GMT</pubDate>
    <dc:creator>EugeneHiihtaja</dc:creator>
    <dc:date>2020-02-06T07:52:30Z</dc:date>
    <item>
      <title>LPC55S69: USB SRAM usage in ROM</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/LPC55S69-USB-SRAM-usage-in-ROM/m-p/991934#M39050</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi !&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="color: #51626f; background-color: #ffffff; border: 0px; font-size: 14px;"&gt;I try to see if USB_SRAM at ox50100000 can be used for keep some data over reboot.&lt;/P&gt;&lt;P style="color: #51626f; background-color: #ffffff; border: 0px; font-size: 14px;"&gt;And it seems to me it is wiped by 0x00 by ROM code every reboot even ISP USB flashing is not used.&lt;/P&gt;&lt;P style="color: #51626f; background-color: #ffffff; border: 0px; font-size: 14px;"&gt;SRAM4 area at 0x30040000 is keep data over reboot for example.&lt;/P&gt;&lt;P style="color: #51626f; background-color: #ffffff; border: 0px; font-size: 14px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P style="color: #51626f; background-color: #ffffff; border: 0px; font-size: 14px;"&gt;Could you look in what cases USB_RAM wiped ? All the time over reboot or in some cases.&lt;/P&gt;&lt;P style="color: #51626f; background-color: #ffffff; border: 0px; font-size: 14px;"&gt;Can it be disabled some how in any setting if USB ISP flashing is&amp;nbsp; not planned to be used at all ?&lt;/P&gt;&lt;P style="color: #51626f; background-color: #ffffff; border: 0px; font-size: 14px;"&gt;My application need a lot of SRAM and USB_SRAM need as well.&lt;/P&gt;&lt;P style="color: #51626f; background-color: #ffffff; border: 0px; font-size: 14px;"&gt;&lt;/P&gt;&lt;P style="color: #51626f; background-color: #ffffff; border: 0px; font-size: 14px;"&gt;USB_SRAM is not mentioned in any Linked files and regular firmware is not counted it as bss are and not zeroed it for sure.&lt;/P&gt;&lt;P style="color: #51626f; background-color: #ffffff; border: 0px; font-size: 14px;"&gt;&lt;/P&gt;&lt;P style="color: #51626f; background-color: #ffffff; border: 0px; font-size: 14px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P style="color: #51626f; background-color: #ffffff; border: 0px; font-size: 14px;"&gt;Regards,&lt;/P&gt;&lt;P style="color: #51626f; background-color: #ffffff; border: 0px; font-size: 14px;"&gt;Eugene&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 06 Feb 2020 07:52:30 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/LPC55S69-USB-SRAM-usage-in-ROM/m-p/991934#M39050</guid>
      <dc:creator>EugeneHiihtaja</dc:creator>
      <dc:date>2020-02-06T07:52:30Z</dc:date>
    </item>
    <item>
      <title>Re: LPC55S69: USB SRAM usage in ROM</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/LPC55S69-USB-SRAM-usage-in-ROM/m-p/991935#M39051</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi, Eugene,&lt;/P&gt;&lt;P&gt;This is SDK example, as you can see the the screenshot, the USB_SRAM space is used exactly. If you want to use the USB_RAM, you can use it as the following line:&lt;/P&gt;&lt;P&gt;For example, you can use the code to save the array to USB_RAM&lt;/P&gt;&lt;P&gt;#include "cr_section_macros.h"&lt;/P&gt;&lt;P&gt;__NOINIT(USB_RAM) char noinit_buffer[128];&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;For detailed information, pls refer to the following part.&lt;/P&gt;&lt;P&gt;Hope it can help you&lt;/P&gt;&lt;P&gt;BR&lt;/P&gt;&lt;P&gt;XiangJun Rong&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Placement of specific code/data Items&lt;/P&gt;&lt;DIV class=""&gt;&lt;A href="http://127.0.0.1:62562/help/ntopic/com.nxp.lpcxpresso.userguide.docs/htmlProducts/index.html"&gt;MCUXpresso IDE User Guide&lt;/A&gt; &amp;gt; &lt;A href="http://127.0.0.1:62562/help/ntopic/com.nxp.lpcxpresso.userguide.docs/htmlProducts/memoryconfig.html"&gt;Memory Configuration and Linker Scripts&lt;/A&gt;&lt;/DIV&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;H2 class="" style="clear: both;"&gt;&lt;A name="specficcodedata"&gt;&lt;/A&gt;Placement of specific code/data Items&lt;/H2&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;P&gt;It is possible to make changes to the placement of specific code/data items within the final image without modifying the FreeMarker linker script templates. Such placement can be controlled via macros provided in an MCUXpresso IDE supplied header file which can be pulled into your project using:&lt;/P&gt;&lt;DIV class=""&gt;&lt;P&gt;&lt;CODE class=""&gt;#include&amp;nbsp;&amp;lt;cr_section_macros.h&amp;gt;&amp;nbsp;&lt;BR /&gt;&lt;/CODE&gt;&lt;/P&gt;&lt;/DIV&gt;&lt;P&gt;&lt;SPAN class=""&gt;&lt;STRONG&gt;Alternatively&lt;/STRONG&gt;&lt;/SPAN&gt; Introduced in MCUXpresso IDE version 10.2, the managed linker script mechanism now also provides a means of placing arbitrarily named code or data sections into a specified memory region of the generated image and is described in the next section. (See also &lt;A class="" href="http://127.0.0.1:62562/help/ntopic/com.nxp.lpcxpresso.userguide.docs/htmlProducts/globaldataplacement.html" title="Global Data Placement"&gt;Global data placement).&lt;/A&gt;&lt;/P&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;H3 class=""&gt;&lt;A name="placingdata1"&gt;&lt;/A&gt;Placing code and data into different Memory Regions&lt;/H3&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;P&gt;Unlike the macros provided by cr_section_macros.h (described later), this method does not require any change to the source code declaring the affected code/data (which basically rename the generated code/data sections to match the memory region name). And in many cases it can avoid the need to provide project local FreeMarker linker script templates (described later in this chapter).&lt;/P&gt;&lt;P&gt;To place the code or data, you simply need to add the details of the section name, the memory region to place it in, and the type of the code/data, as per the below screenshot(s):&lt;/P&gt;&lt;DIV class=""&gt;&lt;A name="figure.extralinkersection"&gt;&lt;/A&gt;&lt;P class=""&gt;&lt;STRONG&gt;Figure&amp;nbsp;18.30.&amp;nbsp;Adding an Extra Linker Section&lt;/STRONG&gt;&lt;/P&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;TABLE border="0" style="cellpadding: 0; cellspacing: 0;" summary="manufactured viewport for HTML img" width="461"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;&lt;IMG alt="Adding an Extra Linker Section" src="http://127.0.0.1:62562/help/ntopic/com.nxp.lpcxpresso.userguide.docs/images/MCUX_extralinkersection.jpeg" width="461" /&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;which will modify the generated linker script to contain the sections specified in the appropriate region:&lt;/P&gt;&lt;DIV class=""&gt;&lt;A name="figure.extralinkersectionscript"&gt;&lt;/A&gt;&lt;P class=""&gt;&lt;STRONG&gt;Figure&amp;nbsp;18.31.&amp;nbsp;Extra Linker Section Script&lt;/STRONG&gt;&lt;/P&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;TABLE border="0" style="cellpadding: 0; cellspacing: 0;" summary="manufactured viewport for HTML img" width="283"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;&lt;IMG alt="Extra Linker Section Script" src="http://127.0.0.1:62562/help/ntopic/com.nxp.lpcxpresso.userguide.docs/images/MCUX_extralinkersectionscript.jpeg" width="283" /&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The second example graphic shows both the placement of a constant data table and also the powerful technique of specifying a project source folder and placing the entire contents of that folder (flash2’s .text sections) into a chosen flash device. Using this scheme the user can drag and drop source files within the project structure to choose which location will be used for their linkage and so their flash storage.&lt;/P&gt;&lt;DIV class=""&gt;&lt;A name="figure.extralinkersection2"&gt;&lt;/A&gt;&lt;P class=""&gt;&lt;STRONG&gt;Figure&amp;nbsp;18.32.&amp;nbsp;Adding an Extra Linker 2 Section&lt;/STRONG&gt;&lt;/P&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;TABLE border="0" style="cellpadding: 0; cellspacing: 0;" summary="manufactured viewport for HTML img" width="354"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;&lt;IMG alt="Adding an Extra Linker 2 Section" src="http://127.0.0.1:62562/help/ntopic/com.nxp.lpcxpresso.userguide.docs/images/MCUX_extralinkersection1.jpeg" width="354" /&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class=""&gt;&lt;STRONG&gt;Note&lt;/STRONG&gt;&lt;/SPAN&gt;: that the format of the “input section description” is as detailed in the GNU Linker documentation, which can be found within the IDE’s built-in help system :&lt;/P&gt;&lt;P&gt;&lt;SPAN class=""&gt;Help -&amp;gt; Help Contents -&amp;gt; Tools (Compilers, Debugger, Utilities) -&amp;gt; GNU Linker -&amp;gt; Linker Scripts -&amp;gt; SECTIONS Command -&amp;gt; Input Section Description&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;or directly in the online GNU documentation at:&lt;/P&gt;&lt;P&gt;&lt;A class="" href="https://sourceware.org/binutils/docs/ld/Input-Section-Basics.html" target="_top"&gt;https://sourceware.org/binutils/docs/ld/Input-Section-Basics.html&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Also, this &lt;SPAN class=""&gt;function&lt;/SPAN&gt;ality only allows you to add sections to the linker script, not to remove something that the managed linker script already puts in. Thus if you need to remove part of the generated linker script’s contents – then you will still need to modify the underlying FreeMarker linker script templates.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Finally, remember that the GNU linker script mechanism &lt;SPAN class=""&gt;function&lt;/SPAN&gt;s such that the first match encountered for a section will win (not the best match found). Thus this mechanism is just a request, not a guarantee. Always check the generated linker script and the map file output by the link step to confirm the expected placement of sections. In some problem cases, you may be able to force the required placement by use of an EXCLUDE in one memory region, as well as the section in the required region.&lt;/SPAN&gt;&lt;/P&gt;&lt;/DIV&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;H3 class=""&gt;&lt;A name="PlacingdataintodifferentRAMblocksusingMacros"&gt;&lt;/A&gt;&lt;SPAN&gt;Placing data into different &lt;SPAN class=""&gt;RAM&lt;/SPAN&gt; blocks using Macros&lt;/SPAN&gt;&lt;/H3&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;P&gt;&lt;SPAN&gt;Many MCUs provide more than one bank of &lt;SPAN class=""&gt;RAM&lt;/SPAN&gt;. By default the managed linker script mechanism will place all of the application data and bss (as well as the heap and stack) into the first bank of &lt;SPAN class=""&gt;RAM&lt;/SPAN&gt;.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;However it is also possible to place specific data or bss items into any of the defined banks for the target MCU, as displayed in the Memory Configuration Editor, by decorating their definitions in your source code with macros from the cr_section_macros.h MCUXpresso IDE supplied header file&lt;/P&gt;&lt;P&gt;For simplicity, the &lt;SPAN class=""&gt;&lt;STRONG&gt;additional&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN&gt; memory regions are named sequentially, starting from 2, so &lt;SPAN class=""&gt;RAM&lt;/SPAN&gt;2, &lt;SPAN class=""&gt;RAM&lt;/SPAN&gt;3 etc (as well as using their “formal” region name – for example &lt;SPAN class=""&gt;Ram&lt;/SPAN&gt;AHB32). &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;For example, the LPC1768 has a second bank of &lt;SPAN class=""&gt;RAM&lt;/SPAN&gt; at address 0x2007c000. The managed linker script mechanism creates a data (and equivalent bss) load section for this region thus:&lt;/SPAN&gt;&lt;/P&gt;&lt;DIV class=""&gt;&lt;P&gt;&lt;CODE class=""&gt;&lt;SPAN&gt;.data_&lt;SPAN class=""&gt;RAM&lt;/SPAN&gt;2&amp;nbsp;:&amp;nbsp;ALIGN(4)&amp;nbsp;&lt;/SPAN&gt;&lt;BR /&gt; {&amp;nbsp;&lt;BR /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;FILL(0xff)&lt;BR /&gt;&lt;SPAN&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;*(.data.$&lt;SPAN class=""&gt;RAM&lt;/SPAN&gt;2*)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;*(.data.$&lt;SPAN class=""&gt;Ram&lt;/SPAN&gt;AHB32*)&amp;nbsp;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; }&amp;nbsp;&amp;gt;&amp;nbsp;&lt;SPAN class=""&gt;Ram&lt;/SPAN&gt;AHB32&amp;nbsp;AT&amp;gt;MFlash512&lt;/SPAN&gt;&lt;BR /&gt;&lt;/CODE&gt;&lt;/P&gt;&lt;/DIV&gt;&lt;P&gt;To place data into this section, you can use the __DATA macro, thus:&lt;/P&gt;&lt;DIV class=""&gt;&lt;P&gt;&lt;CODE class=""&gt;&lt;SPAN&gt;//&amp;nbsp;create&amp;nbsp;an&amp;nbsp;unitialised&amp;nbsp;1k&amp;nbsp;buffer&amp;nbsp;in&amp;nbsp;&lt;SPAN class=""&gt;RAM&lt;/SPAN&gt;2&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; __DATA(&lt;SPAN class=""&gt;RAM&lt;/SPAN&gt;2)&amp;nbsp;char&amp;nbsp;data_buffer[1024];&amp;nbsp;&lt;/SPAN&gt;&lt;BR /&gt;&lt;/CODE&gt;&lt;/P&gt;&lt;/DIV&gt;&lt;P&gt;Or the __BSS macro:&lt;/P&gt;&lt;DIV class=""&gt;&lt;P&gt;&lt;CODE class=""&gt;&lt;SPAN&gt;//&amp;nbsp;create&amp;nbsp;a&amp;nbsp;zero-init&amp;nbsp;buffer&amp;nbsp;in&amp;nbsp;&lt;SPAN class=""&gt;RAM&lt;/SPAN&gt;2&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; __BSS(&lt;SPAN class=""&gt;RAM&lt;/SPAN&gt;2)&amp;nbsp;char&amp;nbsp;bss_buffer[128];&lt;/SPAN&gt;&lt;BR /&gt;&lt;/CODE&gt;&lt;/P&gt;&lt;/DIV&gt;&lt;P&gt;&lt;SPAN&gt;In some cases you might need a finer level of granularity than just placing a variable into a specific memory bank, and rather need to place it at a specific address. In such a case you could then edit the predefined memory layout for your particular project using the “Memory Configuration Editor” to divide up (and rename) the existing banks of &lt;SPAN class=""&gt;RAM&lt;/SPAN&gt;. This then allows you to provide a specific named block of &lt;SPAN class=""&gt;RAM&lt;/SPAN&gt; into which to place the variable that you need at a specific address, again by using the attribute macros provided by the “cr_section_macros.h” header file.&lt;/SPAN&gt;&lt;/P&gt;&lt;/DIV&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;H3 class=""&gt;&lt;A name="NoinitMemorySections"&gt;&lt;/A&gt;Noinit Memory Sections&lt;/H3&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;P&gt;&lt;SPAN&gt;Normally global variables in an application will end up in either a “.data” (initialized) or “.bss” (zero-initialized) data section within your linked application. Then when your application starts executing, the startup code will automatically copy the initial values of “.data” sections from Flash to &lt;SPAN class=""&gt;RAM&lt;/SPAN&gt;, and zero-initialize “.bss” data sections directly in &lt;SPAN class=""&gt;RAM&lt;/SPAN&gt;.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;MCUXpresso IDE’s managed linker script mechanism also supports the use of “.noinit” data within your application. Such data is similar to “.bss” except that it will not get zero-initialized during startup.&lt;/P&gt;&lt;P&gt;&lt;SPAN class=""&gt;&lt;STRONG&gt;Note&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN&gt;: Great care must be taken when using “.noinit” data such that your application code makes no assumptions about the initial value of such data. This normally means that your application code will need to explicitly set up such data before using it – otherwise the initial value of such a global variable will basically be random (i.e. it will depend upon the value that happens to be in &lt;SPAN class=""&gt;RAM&lt;/SPAN&gt; when your system powers up). &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;One common example of using such .noinit data items is in defining the f&lt;SPAN class=""&gt;ram&lt;/SPAN&gt;e buffer stored in SD&lt;SPAN class=""&gt;RAM&lt;/SPAN&gt; in applications which use an onchip LCD controller (for example NXP LPC178x and LPC408x parts). &lt;/SPAN&gt;&lt;/P&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;H4 class=""&gt;&lt;A name="MakingglobalvariablesNoinit"&gt;&lt;/A&gt;Making global variables Noinit&lt;/H4&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;P&gt;&lt;SPAN&gt;The linker script generated by the MCUXpresso IDE managed linker script mechanism will contain a section for each &lt;SPAN class=""&gt;RAM&lt;/SPAN&gt; memory block to contain “.noinit” items, as well as the “.data” and “.bss” items. &lt;/SPAN&gt;&lt;SPAN class=""&gt;&lt;STRONG&gt;Note&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN&gt;: For a particular &lt;SPAN class=""&gt;RAM&lt;/SPAN&gt; memory block, all “.data” items will be placed first, followed by “.bss” items, and then “.noinit” items. &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;However, normally for a particular &lt;SPAN class=""&gt;RAM&lt;/SPAN&gt; memory block where you are going to be put “.noinit” items, you would actually be making all of the data placed into that &lt;SPAN class=""&gt;RAM&lt;/SPAN&gt; “.noinit”.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;The “cr_section_macros.h” header file then defines macros which can be used to place global variables into the appropriate “.noinit” section. First of all include this header file:&lt;/P&gt;&lt;DIV class=""&gt;&lt;P&gt;&lt;CODE class=""&gt;#include&amp;nbsp;&amp;lt;cr_section_macros.h&amp;gt;&lt;BR /&gt;&lt;/CODE&gt;&lt;/P&gt;&lt;/DIV&gt;&lt;P&gt;The __NOINIT macro can then be used thus:&lt;/P&gt;&lt;DIV class=""&gt;&lt;P&gt;&lt;CODE class=""&gt;&lt;SPAN&gt;//&amp;nbsp;create&amp;nbsp;a&amp;nbsp;128&amp;nbsp;byte&amp;nbsp;noinit&amp;nbsp;buffer&amp;nbsp;in&amp;nbsp;&lt;SPAN class=""&gt;RAM&lt;/SPAN&gt;2&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; __NOINIT(&lt;SPAN class=""&gt;RAM&lt;/SPAN&gt;2)&amp;nbsp;char&amp;nbsp;noinit_buffer[128];&lt;/SPAN&gt;&lt;BR /&gt;&lt;/CODE&gt;&lt;/P&gt;&lt;/DIV&gt;&lt;P&gt;&lt;SPAN&gt;And if you want “.noinit” items placed into the default &lt;SPAN class=""&gt;RAM&lt;/SPAN&gt; bank, then you can use the __NOINIT_DEF macro thus:&lt;/SPAN&gt;&lt;/P&gt;&lt;DIV class=""&gt;&lt;P&gt;&lt;CODE class=""&gt;&lt;SPAN&gt;//&amp;nbsp;create&amp;nbsp;a&amp;nbsp;noinit&amp;nbsp;integer&amp;nbsp;variable&amp;nbsp;in&amp;nbsp;the&amp;nbsp;main&amp;nbsp;block&amp;nbsp;of&amp;nbsp;&lt;SPAN class=""&gt;RAM&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;BR /&gt; __NOINIT_DEF&amp;nbsp;int&amp;nbsp;noinit_var&amp;nbsp;;&lt;BR /&gt;&lt;/CODE&gt;&lt;/P&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;H3 class=""&gt;&lt;A name="PlacingcoderodataintodifferentFLASHBlocks"&gt;&lt;/A&gt;Placing code/rodata into different FLASH Blocks&lt;/H3&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;P&gt;Most MCUs only have one bank of Flash memory. But with some parts more than one bank may be available – and in such cases, by default, the managed linker script mechanism will still place all of the application code and rodata (consts) into the first bank of Flash (as displayed in the Memory Configuration Editor).&lt;/P&gt;&lt;P&gt;For example:&lt;/P&gt;&lt;DIV class=""&gt;&lt;UL class="" style="list-style-type: disc;"&gt;&lt;LI class=""&gt;&lt;P&gt;most of the LPC18 and LPC43xx parts containing internal Flash (such as LPC1857 and LPC4357) actually provide dual banks of Flash.&lt;/P&gt;&lt;/LI&gt;&lt;LI class=""&gt;&lt;P&gt;some MCUs have the ability to access external Flash (typically SPIFI) as well as their built-in internal Flash (e.g. LPC18xx, LPC40xx, LPC43xx, LPC546xx).&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;/DIV&gt;&lt;P&gt;&lt;SPAN&gt;However it is also possible to place specific &lt;SPAN class=""&gt;function&lt;/SPAN&gt;s or rodata items into the second (or even third) bank of Flash. This placement is controlled via macros provided in the &lt;/SPAN&gt;&lt;SPAN class=""&gt;"cr_section_macros.h"&lt;/SPAN&gt; header file.&lt;/P&gt;&lt;P&gt;For simplicity, the &lt;SPAN class=""&gt;&lt;STRONG&gt;additional&lt;/STRONG&gt;&lt;/SPAN&gt; Flash region can be referenced as Flash2 (as well as using its “formal” region name – for example MFlashB512 – which will vary depending upon part).&lt;/P&gt;&lt;P&gt;First of all include this header file:&lt;/P&gt;&lt;DIV class=""&gt;&lt;P&gt;&lt;CODE class=""&gt;#include&amp;nbsp;&amp;lt;cr_section_macros.h&amp;gt;&lt;BR /&gt;&lt;/CODE&gt;&lt;/P&gt;&lt;/DIV&gt;&lt;P&gt;Then, for example, to place a rodata item into this section, you can use the __RODATA macro, thus:&lt;/P&gt;&lt;DIV class=""&gt;&lt;P&gt;&lt;CODE class=""&gt;__RODATA(Flash2)&amp;nbsp;const&amp;nbsp;int&amp;nbsp;roarray[]&amp;nbsp;=&amp;nbsp;{10,20,30,40,50};&lt;BR /&gt;&lt;/CODE&gt;&lt;/P&gt;&lt;/DIV&gt;&lt;P&gt;&lt;SPAN&gt;Or to place a &lt;SPAN class=""&gt;function&lt;/SPAN&gt; into it you can use __TEXT macro:&lt;/SPAN&gt;&lt;/P&gt;&lt;DIV class=""&gt;&lt;P&gt;&lt;CODE class=""&gt;__TEXT(Flash2)&amp;nbsp;void&amp;nbsp;systick_delay(uint32_t&amp;nbsp;delayTicks)&amp;nbsp;{&amp;nbsp;&lt;BR /&gt; &amp;nbsp;:&lt;BR /&gt; }&amp;nbsp;&lt;BR /&gt;&lt;/CODE&gt;&lt;/P&gt;&lt;/DIV&gt;&lt;P&gt;&lt;SPAN&gt;In addition, the __RODATA_EXT and __TEXT_EXT macros can be used to place &lt;SPAN class=""&gt;function&lt;/SPAN&gt;s/rodata into a more specifically named section, for example:&lt;/SPAN&gt;&lt;/P&gt;&lt;DIV class=""&gt;&lt;P&gt;&lt;CODE class=""&gt;__TEXT_EXT(Flash2,systick_delay)&amp;nbsp;void&amp;nbsp;systick_delay(uint32_t&amp;nbsp;delayTicks)&amp;nbsp;{&amp;nbsp;&lt;BR /&gt; &amp;nbsp;:&lt;BR /&gt; }&amp;nbsp;&lt;BR /&gt;&lt;/CODE&gt;&lt;/P&gt;&lt;/DIV&gt;&lt;P&gt;will be placed into the section “.text.$Flash2.systick_delay” rather than “.text.$Flash2”.&lt;/P&gt;&lt;/DIV&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;H3 class=""&gt;&lt;A name="PlacingspecificfunctionsintoRAMBlocks"&gt;&lt;/A&gt;&lt;SPAN&gt;&lt;SPAN&gt;Placing specific &lt;SPAN class=""&gt;function&lt;/SPAN&gt;s into &lt;/SPAN&gt;&lt;SPAN class=""&gt;RAM&lt;/SPAN&gt; Blocks&lt;/SPAN&gt;&lt;/H3&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;P&gt;In most modern MCUs with built-in Flash memory, code is normally executed directly from Flash memory. Various techniques, such as prefetch buffering are used to ensure that code will execute with minimal or zero wait states, even a higher clock frequencies. Please see the documentation for the MCU that you are using for more details.&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&lt;SPAN&gt;However it is also possible to place specific &lt;SPAN class=""&gt;function&lt;/SPAN&gt;s into any of the defined banks of &lt;/SPAN&gt;&lt;SPAN class=""&gt;RAM&lt;/SPAN&gt; for the target MCU, as displayed in:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class=""&gt;Project -&amp;gt; Properties -&amp;gt; C/C++ Build -&amp;gt; MCU settings&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&lt;SPAN&gt;and sometimes there can be advantages in relocating small, time critical &lt;SPAN class=""&gt;function&lt;/SPAN&gt;s so that they run out of &lt;/SPAN&gt;&lt;SPAN class=""&gt;RAM&lt;/SPAN&gt; instead of Flash.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;For simplicity, the &lt;SPAN class=""&gt;&lt;STRONG&gt;additional&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN&gt; memory regions are named sequentially, starting from 2, (as well as using their “formal” region name – for example &lt;SPAN class=""&gt;Ram&lt;/SPAN&gt;AHB32). So for a device with 3 &lt;SPAN class=""&gt;RAM&lt;/SPAN&gt; regions, alias names &lt;SPAN class=""&gt;RAM&lt;/SPAN&gt;, &lt;SPAN class=""&gt;RAM&lt;/SPAN&gt;2 and &lt;SPAN class=""&gt;RAM&lt;/SPAN&gt;3 will be available. &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;This placement is controlled via macros provided in a header file which can be pulled into your project using:&lt;/P&gt;&lt;DIV class=""&gt;&lt;P&gt;&lt;CODE class=""&gt;#include&amp;nbsp;&amp;lt;cr_section_macros.h&amp;gt;&lt;BR /&gt;&lt;/CODE&gt;&lt;/P&gt;&lt;/DIV&gt;&lt;P&gt;&lt;SPAN&gt;The macro __&lt;SPAN class=""&gt;RAM&lt;/SPAN&gt;&lt;SPAN&gt;FUNC can be used to locate a &lt;SPAN class=""&gt;function&lt;/SPAN&gt; into a specific &lt;/SPAN&gt;&lt;SPAN class=""&gt;RAM&lt;/SPAN&gt; region.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&lt;SPAN&gt;For example, to place a &lt;SPAN class=""&gt;function&lt;/SPAN&gt; into the main &lt;/SPAN&gt;&lt;SPAN class=""&gt;RAM&lt;/SPAN&gt; region, use:&lt;/SPAN&gt;&lt;/P&gt;&lt;DIV class=""&gt;&lt;P&gt;&lt;CODE class=""&gt;&lt;SPAN&gt;__&lt;SPAN class=""&gt;RAM&lt;/SPAN&gt;FUNC(&lt;SPAN class=""&gt;RAM&lt;/SPAN&gt;)&amp;nbsp;void&amp;nbsp;foo&lt;SPAN class=""&gt;RAM&lt;/SPAN&gt;(void)&amp;nbsp;{...&lt;/SPAN&gt;&lt;BR /&gt;&lt;/CODE&gt;&lt;/P&gt;&lt;/DIV&gt;&lt;P&gt;&lt;SPAN&gt;&lt;SPAN&gt;To place a &lt;SPAN class=""&gt;function&lt;/SPAN&gt; into the &lt;/SPAN&gt;&lt;SPAN class=""&gt;RAM&lt;/SPAN&gt;2 region, use:&lt;/SPAN&gt;&lt;/P&gt;&lt;DIV class=""&gt;&lt;P&gt;&lt;CODE class=""&gt;&lt;SPAN&gt;__&lt;SPAN class=""&gt;RAM&lt;/SPAN&gt;FUNC(&lt;SPAN class=""&gt;RAM&lt;/SPAN&gt;2)&amp;nbsp;void&amp;nbsp;foo&lt;SPAN class=""&gt;RAM&lt;/SPAN&gt;2(void)&amp;nbsp;{...&lt;/SPAN&gt;&lt;BR /&gt;&lt;/CODE&gt;&lt;/P&gt;&lt;/DIV&gt;&lt;P&gt;&lt;SPAN&gt;Alternatively, &lt;SPAN class=""&gt;RAM&lt;/SPAN&gt; can be selected by formal name (as listed in the memory configuration editor), for example:&lt;/SPAN&gt;&lt;/P&gt;&lt;DIV class=""&gt;&lt;P&gt;&lt;CODE class=""&gt;&lt;SPAN&gt;__&lt;SPAN class=""&gt;RAM&lt;/SPAN&gt;FUNC(&lt;SPAN class=""&gt;Ram&lt;/SPAN&gt;AHB32)&amp;nbsp;void&amp;nbsp;Handler&lt;SPAN class=""&gt;RAM&lt;/SPAN&gt;(void)&amp;nbsp;{...&lt;/SPAN&gt;&lt;BR /&gt;&lt;/CODE&gt;&lt;/P&gt;&lt;/DIV&gt;&lt;P&gt;&lt;SPAN&gt;In order to initialize &lt;SPAN class=""&gt;RAM&lt;/SPAN&gt; based code (and data) into specified &lt;SPAN class=""&gt;RAM&lt;/SPAN&gt; banks, the managed linker script mechanism will create a “Global Section Table” in your image, directly after the vector table. This contains the addresses and lengths of each of the data (and bss) sections, so that the startup code can then perform the necessary initialization (copy code/data from Flash to &lt;SPAN class=""&gt;RAM&lt;/SPAN&gt;) .&lt;/SPAN&gt;&lt;/P&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;H4 class=""&gt;&lt;A name="LongbranchveneersandDebugging"&gt;&lt;/A&gt;Long branch veneers and Debugging&lt;/H4&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;P&gt;&lt;SPAN&gt;Due to the distance in the memory map between Flash memory and &lt;SPAN class=""&gt;RAM&lt;/SPAN&gt;&lt;SPAN&gt;, you will typically require a “long branch veneer” between the &lt;SPAN class=""&gt;function&lt;/SPAN&gt; in &lt;/SPAN&gt;&lt;SPAN class=""&gt;RAM&lt;/SPAN&gt;&lt;SPAN&gt; and the calling &lt;SPAN class=""&gt;function&lt;/SPAN&gt; in Flash. The linker can automatically generate such a veneer for direct &lt;SPAN class=""&gt;function&lt;/SPAN&gt; calls, or you can effectively generate your own by using a call via a &lt;SPAN class=""&gt;function&lt;/SPAN&gt; pointer.&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;One point to note is that debugging code with a linker generated veneer can sometimes cause problems. This veneer will not have any source level debug information associated with it, so that if you try to step in to a call to your code in &lt;SPAN class=""&gt;RAM&lt;/SPAN&gt;, typically the debugger will step over it instead.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;You can work around this by single stepping at the instruction level, setting a breakpoint in your &lt;SPAN class=""&gt;RAM&lt;/SPAN&gt;&lt;SPAN&gt; code, or by changing the &lt;SPAN class=""&gt;function&lt;/SPAN&gt; call from a direct one to a call via a &lt;SPAN class=""&gt;function&lt;/SPAN&gt; pointer.&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;H3 class=""&gt;&lt;A name="ReducingCodeSizewhensupportforLPCCRPorKinetisFlashConfigBlockisEnabled"&gt;&lt;/A&gt;Reducing Code Size when support for LPC CRP or Kinetis Flash Config Block is Enabled&lt;/H3&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;P&gt;One of the consequences of the way that LPC CRP and Kinetis Flash Configuration Blocks work is that the memory between the CPU’s vector table and the CRP word/ Flash Config Block is often left largely unused. This can typically increases the size of the application image by several hundred bytes (depending upon the MCU being used).&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;However this unused space can easily be reclaimed by choosing one or more &lt;SPAN class=""&gt;function&lt;/SPAN&gt;s to be placed into this unused memory. To do this, you simply need to decorate their definitions with the macro __AFTER_VECTORS which is supplied in the “cr_section_macros.h” header file&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Obviously in order to do this effectively, you need to identify &lt;SPAN class=""&gt;function&lt;/SPAN&gt;s which will occupy as much of this unused memory as possible. The best way to do this is to look at the linker map file.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;MCUXpresso IDE startup code already uses this macro to place the various initialization &lt;SPAN class=""&gt;function&lt;/SPAN&gt;s and default exception handlers that it contains into this space, thus reducing the ‘default’ unused space. But you can also place additional &lt;SPAN class=""&gt;function&lt;/SPAN&gt;s there by decorating their definitions with the macro, for example&lt;/SPAN&gt;&lt;/P&gt;&lt;DIV class=""&gt;&lt;P&gt;&lt;CODE class=""&gt;&lt;SPAN&gt;__AFTER_VECTORS&amp;nbsp;void&amp;nbsp;myStartup&lt;SPAN class=""&gt;Function&lt;/SPAN&gt;(void);&lt;/SPAN&gt;&lt;BR /&gt;&lt;/CODE&gt;&lt;/P&gt;&lt;/DIV&gt;&lt;P&gt;&lt;SPAN class=""&gt;&lt;STRONG&gt;Note&lt;/STRONG&gt;&lt;/SPAN&gt;: you will get a link error if the __AFTER_VECTORS space grows beyond the CRP/Flash Configuration Block (when this support is enabled):&lt;/P&gt;&lt;DIV class=""&gt;&lt;P&gt;&lt;CODE class=""&gt;myproj_Debug.ld:98&amp;nbsp;cannot&amp;nbsp;move&amp;nbsp;location&amp;nbsp;counter&amp;nbsp;backwards&amp;nbsp;(from&amp;nbsp;00000334&amp;nbsp;&lt;BR /&gt; to&amp;nbsp;000002fc)&lt;BR /&gt; collect2:&amp;nbsp;ld&amp;nbsp;returned&amp;nbsp;1&amp;nbsp;exit&amp;nbsp;status&lt;BR /&gt; make:&amp;nbsp;***&amp;nbsp;[myproj.axf]&amp;nbsp;Error&amp;nbsp;1&lt;BR /&gt;&lt;/CODE&gt;&lt;/P&gt;&lt;/DIV&gt;&lt;P&gt;&lt;SPAN&gt;In this case, you will need to remove the __AFTER_VECTORS macro from the definition of one or more of your &lt;SPAN class=""&gt;function&lt;/SPAN&gt;s.&lt;/SPAN&gt;&lt;/P&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="pastedImage_1.png"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/103257iA32E655B6FB7CCDF/image-size/large?v=v2&amp;amp;px=999" role="button" title="pastedImage_1.png" alt="pastedImage_1.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 10 Feb 2020 04:38:29 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/LPC55S69-USB-SRAM-usage-in-ROM/m-p/991935#M39051</guid>
      <dc:creator>xiangjun_rong</dc:creator>
      <dc:date>2020-02-10T04:38:29Z</dc:date>
    </item>
  </channel>
</rss>

