In KDS and Codewarrior for MCU GCC build, linker will initialize RAM after reset, the enter main function. However in some application, User doesn’t want linker initialize data section. A typical case is when in a bootloader+application combined project, the two program need share the same RAM memory - user application writes data to a shared RAM then invoke bootloader by software reset, bootloader can read the exact data out. The data in shared RAM are not being overwritten by bootloader linker initialization.This article will introduce two methods about how to add uninitialized data section to GCC build.
Method 1. Use NOLOAD keyword in linker file:
NOLOAD : The section should be marked as not loadable, so that it will not be loaded into memory when the program is run. For example in below section .buffram and .bss2 are addressed as “NOLOAD” and doesn’t need to be loaded when the program starts to run.
For detail, see article on MCU on Eclipse: http://mcuoneclipse.com/2014/04/19/gnu-linker-can-you-not-initialize-my-variable/
Method 2. Use pointer in C code for uninitialized RAM.
This method doesn’t use NOLOAD. Here are the steps to utilize it:
Step1: don’t define uninitialized RAM in linker file.
Step2: in C file, use point to access the uninitialized address.
For detail, see attached document with demo listed.