Option to Fill Unused Flash Memory With User Defined Fill Pattern [Imported Thread]
MSP430 Best Flash Practices recommends filling unused code space with a specific value to help stop runaway code if it runs into unused memory. It would be nice to be able to specify up to a 4 byte pattern
MSP430 Best Flash Practices:
http://processors.wiki.ti.com/index.php/MSP430_Flash_Best_Practices
Idea Originally Posted by: Ben Walden 02/04/2013
14/11/2013 Trevor
I solved this problem with a hybrid approach. 1) I use the assembler to statically fill sections I know will be unused via the FILL directive. The downsides are the number bytes to fill must be an assemble-time constant so you can't use the section start/end/size which aren't known until link-time. And you can only fill with a byte value so filling with an opcode to call a handling routine is out of the question. And as the size of the CODE section changes you have to adjust the section that gets filled to fit. You could instead use DS to fill with zeros only - its size argument can use the section start/end/size so you wouldn't have to adjust the size/location of a statically placed fill section. 2) I have a routine that runs once during initialization and checks the area of flash from the end of the CODE section to the start of my statically filled section. It writes the flash there with the fill value if it hasn't already been filled. 3) I set up my project so that it also generates an intel hex file. I post-process that file to fill in the unused areas. The intel hex is used to program production devices. Thus, outside of development, the runtime flash check routine doesn't need to do any writing. This does the trick but that is a lot of work that would be unnecessary if the linker had a section fill option!
15/08/2013 Trevor
I like this idea. I wonder if it would be possible to do this by creating new sections in the memory map/section placement and then using the assembly FILL directive in the created sections? I intend to try this. BUT, it would be really nice to have a general option to fill unused flash with some value, or at least a section fill attribute in the memory map.
Please sign in to leave a comment.
Comments
0 comments