Part Number: MSP432E401Y
Tool/software: TI C/C++ Compiler
I am attempting to create an object in the flash memory which records information about the reset history of the microcontroller. I want this object, of class ResetInfoContainer (a simple class which has integer and boolean members), to persist in memory through the resets so that it can be accessed on startup to aid in diagnosing any system problems. While I am able to allocate memory to store my ResetInfoContainer object in the flash memory, I am unable to assign any values to it without my program crashing.
I'll outline below the steps I have taken in order to try and implement this feature, in the hope that it's useful in identifying the problem in my code or my understanding.
In the `linker.cmd` file, I added an instruction to create a RESETINFO section in the memory (at address 0x000F0000 with length 0x00010000, though these values are arbitrary). In my code I then attempted to instruct the compiler to store my ResetInfoContainer object in the RESETINFO section using the instruction: `#pragma DATA_SECTION(".resetinfo") \n ResetInfoContainer reset_info_container`. This works to some extent. The memory browser indicates that some memory has been allocated at 0x000f000 for the reset_container_object, however when I run the debugger, I am taken immediately to the `abort()` function in `exit.c`. (Confusingly I also get a warning that my #pragma instruction is unrecognised, but I can't make sense of this given that the memory allocation seems to have worked.)
With the above unsuccessful, I tried instead using the the location pragma; I used the instruction: `#pragma LOCATION(0xf0000) \n ResetInfoContainer reset_info_container;` to attempt to initialise this object in the RESETINFO section (though through inelegant hard-coding of the memory address). Very similar to above, the memory for the object seems to have been allocated, but no values can be stored in it without the program crashing.
In both cases when the program fails, the decoded exception in the Hwi module (in the RTOS Object View) reads: "Hard Fault: FORCED: BUSFAULT: PRECISERR.Data Access Error. Address = 0xf0000." I thought that this could be a problem with the write access of the flash memory, but when I retrieve the flash protection status of the section at 0x000f0000 it returns `FlashReadWrite`.
I'm unsure how to continue to look for solutions to this problem, so any help would be much appreciated!
I based my code off the solution given in this forum thread -
- with some syntactic alterations for the C++ compiler, described here -
.
Here are the files involved in the problem: