0
\$\begingroup\$

I am using MSP430F5340 MCU, IDE is IAR workbench,today after adding some lines of code, I found my data that previously stored in flash was crashed. So I supposed the code memory size in flash has beyond the data flash boundary. This MCU has total 64K flash (0xFFFF bytes), my data start address is 0xF400,and ends at 0xF9FF,in total 3 blocks of 0.5K bytes. So from 0x0000-0xF400 (61K) is for code area.

Flash allocation

From the last lines of map file, I found something below:

41196 bytes of CODE  memory
3 022 bytes of DATA  memory (+ 83 absolute )
5 421 bytes of CONST memory

41196+3 022+5 421 <61K bytes, so how could my own data in flash was crashed?

Previously, when my data was not influenced, the map file shows:

39 478 bytes of CODE  memory
3 022 bytes of DATA memory (+ 83 absolute )
4 755 bytes of CONST memory

I wonder the code memory starting address is not 0x00,and after adding some lines, the code area just cover the data area.

Hope someone could help to explain me this matter.

I think this question involves both on firmware and hardware section, so I posted it both places.

The two maps files and MSP430F5340 datasheet were attached.

Map File1 (Data is right): https://drive.google.com/file/d/13g3YaZKI10u1q55rDdmwMBhIGRPOl71d/view?usp=sharing

Map File2 (Data is wrong): https://drive.google.com/file/d/1l5opnbOKgD1kPARb_j0NY6KI2WhXvE9J/view?usp=sharing

Msp430F5340: https://drive.google.com/file/d/1De8R4SqtLIoAC6_SqyonO0Nbdk6oP29L/view?usp=sharing

\$\endgroup\$
8
  • \$\begingroup\$ Your compiler will produce a map file. That will show you where the linker has placed the various segments \$\endgroup\$ – Jason M Jul 1 '20 at 12:01
  • 1
    \$\begingroup\$ This is a little off-topic as not really a hardware question. "Flash was crashed" does not really mean anything. \$\endgroup\$ – Jason M Jul 1 '20 at 12:02
  • \$\begingroup\$ Hi,the map file is too long,I can't understand it.<br/> I mean the data in flash was lost \$\endgroup\$ – Ye Shiwei Jul 1 '20 at 12:12
  • \$\begingroup\$ By "crashed" to you mean "corrupted" or "overwritten" or "erased". Learn to read map files they are important. \$\endgroup\$ – Jason M Jul 1 '20 at 12:14
  • \$\begingroup\$ I know it's important,so I am here to find some help \$\endgroup\$ – Ye Shiwei Jul 1 '20 at 12:16
0
\$\begingroup\$

Already solved this issue. The key point is,from the link file 'lnk430f5340.xcl',I found the flash memory allocation for code area is 0x4400-0xFF7F & 0x10000-0x143FF。
And the code size is '41196 bytes of CODE memory' + '5421 bytes of CONST memory'('3022 bytes of DATA memory' should in RAM)
thus the data at 0xF400 was lost. There are 2 ways to solve it.
1).Put the data to the larger address,for example at 0x13600
2).Modify memory allocation for code area,change it to 0x4400-0xFF3F & 0x10000-0x143FF,so the data at 0xF400 will not be covered.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.