I am not an expert (yet) with FlexNVM. I did some check today, but couldn't find definite answer.
Our colleagues designed FlexNVM in a relatively complicated way to learn and use. (Just search FlexNVM, there are many questions raised.) also documentation on this can be further improved.
I have 2 guesses for your issue.
(1) is that after partitioning, with default values in codes, all 256KB D-Flash are turned into EEPROM backup space. My guess is in this case, the flash space is no longer accessible with addresses. So when trying to load data in FREESCALE_PROD_DATA area (e.g. *((uint32_t*)gRngSeedStorageAddr_d) ), a bus access error would occur and results as a hard fault.
It is easy to test this, just try: * (uint32_t *) 0x0007F7F8
This would read the address in the previous flash sector (shown in your picture as 0xFFFFFFFF). Or try any other address in the D-FLASH area. If all accesses can trigger hard fault, then this region is no longer accessible.
Btw, in your debugger (memory) window, it shows values of 0xFFFFFFFFs, but this maybe cached. And could become ???????? as well.
(2) is that in KW36 user manual, section 29.4.11.16 Program Partition command.
It says "Prior to launching the Program Partition command, the data flash IFR must be in an erased state, which can be accomplished by executing the Erase All Blocks command or by an external request ..."
The "external request" is probably submitted by a debugger. Then, from user codes, the only way is to issue an Erase All Blocks command to the whole D-Flash area. (This is my understanding to the sentence.)
And when looking at the KW36 demo codes, this is clearly not done before the partition command. And it is not designed this way, because the FREESCALE_PROD_DATA is placed at the end of the D-FLASH. A Erase-All would remove the factory production data.
Summary, I would do it this way,
- copy out the FREESCALE_PROD_DATA, and relocate it to a different flash sector
- do a full erase of D-flash, and then partition the flash. (Note that this is only need 1 time, can be done at factory manufacturing)
- then don't access the EEPROM Backup space with address, but only via the FlexRAM.