From 0e95629eb1cca652447d9c30514319272af2f337 Mon Sep 17 00:00:00 2001 From: Tomas Vanek Date: Fri, 22 Jul 2016 12:28:42 +0200 Subject: flash Kinetis: Implement flash protection setting Kinetis family employs strange concept of Flash Configuration Field at address 0x400 of program flash. Writing incorrect data to FCF may permanently lock the device. The change introduces 'kinetis fcf_source protection' mode. In this mode write of flash image data to FCF is prevented. FCF data build from protection (set by 'flash protect' command) are written instead. FCF data are written also just after erase of relevant sector. It protects device from locking security by reset or power cycle after erase. prot_blocks array is used as protection blocks have bigger size than sectors. Alignment and padding programming sections is rewritten to fix writing with not section boundary aligned begin. Change-Id: I9fc8bd37d6f627fb8ed7abb7f7560e78a740b195 Signed-off-by: Tomas Vanek Reviewed-on: http://openocd.zylin.com/3562 Reviewed-by: Andreas Fritiofson Tested-by: jenkins --- doc/openocd.texi | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'doc') diff --git a/doc/openocd.texi b/doc/openocd.texi index 74e5e887..81466546 100644 --- a/doc/openocd.texi +++ b/doc/openocd.texi @@ -5288,6 +5288,23 @@ identification register, and autoconfigures itself. flash bank $_FLASHNAME kinetis 0 0 0 0 $_TARGETNAME @end example +@deffn Command {kinetis fcf_source} [protection|write] +Select what source is used when writing to a Flash Configuration Field. +@option{protection} mode builds FCF content from protection bits previously +set by 'flash protect' command. +This mode is default. MCU is protected from unwanted locking by immediate +writing FCF after erase of relevant sector. +@option{write} mode enables direct write to FCF. +Protection cannot be set by 'flash protect' command. FCF is written along +with the rest of a flash image. +@emph{BEWARE: Incorrect flash configuration may permanently lock the device!} +@end deffn + +@deffn Command {kinetis fopt} [num] +Set value to write to FOPT byte of Flash Configuration Field. +Used in kinetis 'fcf_source protection' mode only. +@end deffn + @deffn Command {kinetis mdm check_security} Checks status of device security lock. Used internally in examine-end event. @end deffn -- cgit v1.2.3-18-g5258