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.
I use S32DS for MPC5744P, and I tried to use the keyword NOLOAD, but it seems that it doesn't work correctly.
If I don't initialize the specific RAM memory in the startup, and then I read or write the uninitialize RAM, Every time ECU power on and the MCU will generate a IVOR1 error.
But if I initialize the specific RAM memory which is shared by application and bootloader in the startup, and in application I write data to a shared RAM then invoke bootloader by software reset, bootloader can not read the exact data out.
Above all, If I want to read or write RAM memory in S32DS for MPC57xx, I must initialize the RAM memory in startup, or it will generate an IVOR1 error when ECU power on. Is it right? Thanks.
This document is for KDS and Codewarrior for Kinetis GCC build.
if you have question regarding to S32DS for MPC5744P, I would suggest you ask question in S32DS space: https://community.nxp.com/community/s32/s32ds