'Noinit' Memory Sections
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 RAM, and zero-initialize ".bss" data sections directly in RAM.
Code Red IDE v5.0.14 introduced an enhancement to the managed linker script mechanism so as to also support the use of ".noinit" data within your application. Such data is similar to ".bss" except that it will not get zero-initialized during startup.
Note : 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 RAM when your system powers up).
One common example of using such .noinit data items is in defining the frame buffer stored in SDRAM in applications which use an onchip LCD controller (for example NXP LPC178x and LPC408x parts).
Making global variables noinit
The linker script generated by the Code Red managed linker script mechanism will now contain a section for each RAM memory block to contain ".noinit" items, as well as the ".data" and ".bss" items. Note that for a particular RAM memory block, all ".data" items will be placed first, followed by ".bss" items, and then ".noinit" items.
However, normally for a particular RAM memory block where you are going to be put ".noinit" items, you would actually be making all of the data placed into that RAM ".noinit".
The "cr_section_macros.h" include file then defines macros which can be used to place global variables into the appropriate ".noinit" section.
The __NOINIT macro can be used thus:
__NOINIT(RAM2) char noinit_buffer ; // create a 128 byte noinit buffer in RAM2
And if you want ".noinit" items placed into the default RAM bank, then you can use the __NOINIT_DEF macro thus:
__NOINIT_DEF int noinit_var ; // create a noinit integer variable in the main block of RAM
Linker script template
If you are using the "linker script template" mechanism in your project and you wish to make use of ".noinit" sections, then you will need update your linker template to match the new default one that can be found within <codered_ide_installdir>\<idename>\Wizards\linker.