This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

MSP430F5325: flash memory sections being erased on debugging start, does MSP-FET use mass or segment erase?

Part Number: MSP430F5325

Hello, I setup the last 3 segments in flash for persistent log memory on our project.  I have both the debug/release configuration setup with SMALL code and data models, since our code doesn't need the FLASH2 region.  When I run the code, and the reset the program ('soft reset'), the flash LOG memory that was initialized by my application shows it was written correctly.  But, if I restart the debugger, and the program is reloaded, the flash LOG memory looks like its all erased to 0xFF.   I was hoping when the program is loaded it only flashes the .text and .const memory segments, but maybe its doing a mass erase of the entire flash.  Or something else is going on.  I did reduce the length of FLASH so it only goes to  0xF97F.   I'm not use the info flash region because the log data is larger than the info segments.

FLASH2 : origin = 0x10000,length = 0x43F8 /* Boundaries changed to fix CPU47 */
FLASH : origin = 0x4400, length = 0xB580
FLASH_LOG1 (RW) : origin = 0xF980, length = 0x0200 /* 3 512 byte segments for log data */
FLASH_LOG2 (RW) : origin = 0xFB80, length = 0x0200
FLASH_LOG3 (RW) : origin = 0xFD80, length = 0x0200

#ifndef __LARGE_DATA_MODEL__
.const : {} > FLASH /* Constant data */
.first_day : {} > FLASH_LOG1 type=NOINIT /* log data for test results */
.first_year : {} > FLASH_LOG2 type=NOINIT
.last_year : {} > FLASH_LOG3 type=NOINIT
#else
.const : {} >> FLASH | FLASH2 /* Constant data */
#endif

Here's an example of code where I setup the 'variables' in flash.  I seem to get the same result whether I use const or not.  

#pragma SET_DATA_SECTION(".first_day")
static const uint16_t first_day_log_revision;
static const test_log_struct first_day_log_flash;
#pragma SET_DATA_SECTION()

Here's the map file, showing that everything is allocated correctly.

FLASH 00004400 0000b580 00006192 000053ee RWIX
FLASH_LOG1 0000f980 00000200 000000f3 0000010d RW
FLASH_LOG2 0000fb80 00000200 000000f3 0000010d RW
FLASH_LOG3 0000fd80 00000200 000000f3 0000010d RW

.first_day
* 0 0000f980 000000f3 UNINITIALIZED
0000f980 000000f3 TestLog.obj (.first_day)

.first_year
* 0 0000fb80 000000f3 UNINITIALIZED
0000fb80 000000f3 TestLog.obj (.first_year)

.last_year
* 0 0000fd80 000000f3 UNINITIALIZED
0000fd80 000000f3 TestLog.obj (.last_year)

Code Composer Studio, Version: 10.3.0.00007

  • I tried to change the erase in the debugger setup to 'Erase and download necessary segments only', but then got verification error.

    MSP430: File Loader: Verification failed: Values at address 0x0468A do not match Please verify target memory and memory map.
    MSP430: GEL: File: C:\Users\jerry.morrow\git\jupiter_charger\msp430\Debug\Jupiter Charger.out: a data verification error occurred, file load failed.

  • I suspect you need to move your LOG segments to align with segment boundaries, e.g. move LOG3 to 0xFC00. 

  • This is what I see in the datasheet.  Don't the segments start at 0x4400, and increment by 0x0200 from there?

  • Yes, that's my understanding. So e.g. region LOG3 overlaps with the segment containing the interrupt vectors. I'm not sure what the downloader will do in this case.

    I'm don't know why the verification mismatch popped up at 0x0468A, rather than somewhere near your LOG regions, but I was suggesting fixing some things that are probably causing the downloader some trouble, so we know what we're looking at.

    You might also try the next option ("Replace written") and see what it does. When I used IAR (which has similar options) I briefly understood the distinction between those two options, but that was 10+ years ago. Anyway, it's a quick experiment.

  • 'replace written' option worked!!!  thanks so much

    It was right in front of me, just couldn't see it.

**Attention** This is a public forum