Reserve and use RAM region to store application data on K60

cancel
Showing results for 
Search instead for 
Did you mean: 

Reserve and use RAM region to store application data on K60

364 Views
nikhilsarnaik
Contributor III

Hi,

I am using K60DN512 with MQX 3.8.1 for a project. I want to log runtime errors of my code and send the logfile over when requested or at the startup of application.I want to store the logs in the RAM reserved section, and read it at runtime of the application. Has anyone tried that before. Any pointers how to modify the linker file to reserve RAM space would be really helpful.

PS:  I know MQX has the log module but do not want to use the log module because I presume the logs wont be persistent after power cycle.

Thanks Nikhil

Labels (1)
0 Kudos
1 Reply

188 Views
nikhilsarnaik
Contributor III

Hello all,

I found the answer in the IAR documentation. Hope it would be helpful to someone in future

RESERVING SPACE IN RAM

Often, an application must have an empty uninitialized memory area to be used for

temporary storage, for example a heap or a stack. It is easiest to achieve this at link time.

You must create a block with a specified size and then place it in a memory.

In the linker configuration file, it can look like this:

define block TempStorage with size = 0x1000, alignment = 4 { };

place in RAM { block TempStorage };

To retrieve the start of the allocated memory from the application, the source code could

look like this:

/* Define a section for temporary storage. */

#pragma section = "TEMPSTORAGE"

char *GetTempStorageStartAddress()

{

/* Return start address of section TEMPSTORAGE. */

return __section_begin("TEMPSTORAGE");

}

0 Kudos