cancel
Showing results for 
Search instead for 
Did you mean: 

Saving some data in RAM between Reboots.

Marius CO
Associate III

Hello,

I am trying to add s RAM section at the end of the RAM to save

some data (states) between warm reboots, when the watchdog kicks due some

wiring problems (i2c).

I changed the ld file as:

  • I reduced the stack -2k
  • I reduced ram -2k
  • I created a RAMAUX and afferent section.
/* LD file ... */
/* _estack = 0x20028000;   --  taken out */
_estack = 0x20027800;        /*  new stack - 2K */
 
//...
MEMORY
{
RAM   (xrw)     : ORIGIN  = 0x20000000,  LENGTH = 158K    /* was 160  now is - 2K */
FLASH (rx)      : ORIGIN  = 0x8000000,   LENGTH = 512K
AUXRAM (rx)     : ORIGIN  = 0x1FFFF800,  LENGTH = 0x800    /* use 2 K */
}
 
/// then later on at the end.
 
      .my_ram : {
		KEEP(*(.my_ram))
	} > AUXRAM
 
  /* Remove information from the standard libraries */
 
 

The program wont start.

I hangs in the startup file here:

0690X00000Bvhq3QAB.png

The start hang here. Anything else I am missing.

The intend is to access it in C like

uint32_t ram_end __attribute__((section (".my_ram"))) ;
 
static void* __attribute__((optimize("O0"))) 	_ram_storage(void)
{
	void* ptr = (void*)&ram_end;
	return ptr;
}

Thank you,

... addon

sometime this pops up from atolic

0690X00000BvhqNQAR.png

1 ACCEPTED SOLUTION

Accepted Solutions
KnarfB
Principal III

something like

/* Highest address of the user mode stack */
_estack = ORIGIN(RAM) + LENGTH(RAM);	/* end of "RAM" Ram type memory */
 
_Min_Heap_Size = 0x200 ;	/* required amount of heap  */
_Min_Stack_Size = 0x400 ;	/* required amount of stack */
 
AUXLEN = 2K;
 
/* Memories definition */
MEMORY
{
  RAM	(xrw)	: ORIGIN = 0x20000000,	             LENGTH = 160K-AUXLEN
  AUX   (xrw)   : ORIGIN = ORIGIN(RAM) + LENGTH(RAM) LENGTH = AUXLEN
  FLASH	(rx)	: ORIGIN = 0x8000000,	             LENGTH = 512K
}

View solution in original post

3 REPLIES 3
Clive1 (HNL)
Senior II

The AUXRAM can't be below 0x20000000, you're recovering from the END of memory

The Stack moves downward, so the base for both stack and auxram should be 0x20027800

KnarfB
Principal III

something like

/* Highest address of the user mode stack */
_estack = ORIGIN(RAM) + LENGTH(RAM);	/* end of "RAM" Ram type memory */
 
_Min_Heap_Size = 0x200 ;	/* required amount of heap  */
_Min_Stack_Size = 0x400 ;	/* required amount of stack */
 
AUXLEN = 2K;
 
/* Memories definition */
MEMORY
{
  RAM	(xrw)	: ORIGIN = 0x20000000,	             LENGTH = 160K-AUXLEN
  AUX   (xrw)   : ORIGIN = ORIGIN(RAM) + LENGTH(RAM) LENGTH = AUXLEN
  FLASH	(rx)	: ORIGIN = 0x8000000,	             LENGTH = 512K
}

Marius CO
Associate III

RESOLVED !

Many thanks.

This solved my problem.

... and the elegance of the provided code. Thank you again.