Q:

Persistent RAM variables in NIOS II

I would like to define a C variable in RAM which can survive a CPU reset in NIOS II IDE. Something like __persistent in PIC world or __no_init in Renesas world.
Is there a similar keyword for NIOS compiler, which is based on gcc?

A:

NIOS uses a GCC variant, so you can use the GCC style attributes to place a variable in the .noinit section which basically forgoes any initialisation of the variable. e.g.
char someVar __attribute__ ((section (".noinit")));

The RAM is not cleared during a NIOS processor reset, and GCC wont initialise the value of it, so the variable should survive.
It wouldn't however survive a full FPGA reset/reconfigure as that would reinitialise the RAM entirely. To cope with that you would need external SRAM.

