i.MX8X noinit variables

Showing results for 
Search instead for 
Did you mean: 

i.MX8X noinit variables

Contributor I


MEK-MIMX8QX eval board and NXP rev 2.5.0 SDK.

Developing app in C for the Cortex-M4.

ARM GCC embedded compiler v5.4 2016q3.  (I would like to use a newer one but I believe this is the latest version the current SDK supports.)

Our application requires a few RAM variables declared with the gcc "noinit" attribute so they don't get cleared across a soft reboot of the Cortex-M4.  On the first access of any of these noinit variables, the application crashes.  I don't have a debugger currently so I'm not sure exactly what exception it's hitting.

In the attachment, I've modified the demo hello_world app to show what's going on. I'm building with the "build_release.bat" script.

In hello_world.c I added:

// Attempt #1 - This worked using NXP S32K Design Studio and gcc compiler ...
//int __attribute__ ((section("noinit"))) MyNoInitVariable;
// Attempt #2 - This is what I've seen in various articles on the web ...
int __attribute__ ((section(".noinit"))) MyNoInitVariable;

PRINTF("Before read ...\r\n");
PRINTF("MyNoInitVariable=0x%08x\r\n", MyNoInitVariable);
PRINTF("Before write ...\r\n");
MyNoInitVariable = 0xAAAAAAAA;
PRINTF("After write ...\r\n");

When this runs, only the "Before read ..." printf works, then the application hangs.  As you can see, I tried naming the noinit section "noinit" and also ".noinit" and both versions fail.

NOTE: This exact same application works using the "noinit" section name when I compile and run on an NXP S32K146 eval board.

0 Kudos
1 Reply

NXP TechSupport
NXP TechSupport

For your reference, https://community.nxp.com/docs/DOC-342136 

I am thinking you may also need to add the .noinit in the linker file.

0 Kudos