I'm using MCUXpresso IDE 11.1.0 and SDK 2.6.2. My application is running from Flash starting at 0x60000000. I have a couple of flash areas where the currently executing application (application A), or different application (application B) which is also located in the same flash, can download persistent resources. The resources, as well as application B, each have their own magic number and CRC32 structure that I want to check before using, to ensure that they are intact.
In my Application A Project Properties / C/C++ Build / Settings / MCU Linker / Managed Linker Script / Extra link script input sections, I have created sections for the magic number and CRC32 structures, as well as the resources and Application B themselves, as .noinit section types, so that the linker won't create a binary that could overwrite them. (The magic number and CRC32 structures are actually part of the resource and Application B downloads. Creating separate sections was a convenient way of placing them, undisturbed, in a known location.)
Running DCP_HASH() on the magic number and CRC32 structures appears to work just fine—I passed in the hard-coded addresses and lengths of the respective sections they cover.
But when I try to read the CRC32 part of the structures using the structure names, which can be found the generated map file, I get a hard fault. The fault info is
BFARVALID (7) BusFault Address Register (BFAR) valid flag
PRECISERR (1) Precise data bus error
The FORCED (30) flag is also set. The PC points to where I'm trying to read the first byte of the CRC32 for one Application B.How can I get the persistent data stored in flash?
.noinit areas are defined for RAM areas that will be flagged so that the loader will not try to copy them to ram or initialize them to 0. Basically they exist only in RAM and there is no initialization data in Flash and are not cleared to 0 when the application starts.
I would just exclude the areas where the CRC/MagicNumber are contained from the project, this will prevent the linker from placing anything there.
Then just use pointers to access these areas.