AnsweredAssumed Answered

i.MX8X noinit variables

Question asked by Bob Lawson on Dec 20, 2018
Latest reply on Jan 7, 2019 by jimmychan

Environment:

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.

Attachments

Outcomes