From 7132c002eb698230e3a3b59eace00d87e6b19107 Mon Sep 17 00:00:00 2001
From: utzig <utzig@35acf78f-673a-0410-8e92-d51de3d6d3f4>
Date: Mon, 1 Sep 2014 01:02:07 +0000
Subject: [KINETIS] Add flash protection defaults to HAL

git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@7222 35acf78f-673a-0410-8e92-d51de3d6d3f4
---
 os/hal/ports/KINETIS/K20x/hal_lld.c | 21 +++++++++++++++++++++
 os/hal/ports/KINETIS/KL2x/hal_lld.c | 21 +++++++++++++++++++++
 2 files changed, 42 insertions(+)

(limited to 'os')

diff --git a/os/hal/ports/KINETIS/K20x/hal_lld.c b/os/hal/ports/KINETIS/K20x/hal_lld.c
index 0ca58d0a0..471e23b80 100644
--- a/os/hal/ports/KINETIS/K20x/hal_lld.c
+++ b/os/hal/ports/KINETIS/K20x/hal_lld.c
@@ -37,6 +37,27 @@
 /* Driver local variables and types.                                         */
 /*===========================================================================*/
 
+__attribute__ ((section(".cfmconfig")))
+const uint8_t _cfm[0x10] = {
+  0xFF,  /* NV_BACKKEY3: KEY=0xFF */
+  0xFF,  /* NV_BACKKEY2: KEY=0xFF */
+  0xFF,  /* NV_BACKKEY1: KEY=0xFF */
+  0xFF,  /* NV_BACKKEY0: KEY=0xFF */
+  0xFF,  /* NV_BACKKEY7: KEY=0xFF */
+  0xFF,  /* NV_BACKKEY6: KEY=0xFF */
+  0xFF,  /* NV_BACKKEY5: KEY=0xFF */
+  0xFF,  /* NV_BACKKEY4: KEY=0xFF */
+  0xFF,  /* NV_FPROT3: PROT=0xFF */
+  0xFF,  /* NV_FPROT2: PROT=0xFF */
+  0xFF,  /* NV_FPROT1: PROT=0xFF */
+  0xFF,  /* NV_FPROT0: PROT=0xFF */
+  0x7E,  /* NV_FSEC: KEYEN=1,MEEN=3,FSLACC=3,SEC=2 */
+  0xFF,  /* NV_FOPT: ??=1,??=1,FAST_INIT=1,LPBOOT1=1,RESET_PIN_CFG=1,
+                      NMI_DIS=1,EZPORT_DIS=1,LPBOOT0=1 */
+  0xFF,
+  0xFF
+};
+
 /*===========================================================================*/
 /* Driver local functions.                                                   */
 /*===========================================================================*/
diff --git a/os/hal/ports/KINETIS/KL2x/hal_lld.c b/os/hal/ports/KINETIS/KL2x/hal_lld.c
index 9909f2bd5..63773936f 100644
--- a/os/hal/ports/KINETIS/KL2x/hal_lld.c
+++ b/os/hal/ports/KINETIS/KL2x/hal_lld.c
@@ -37,6 +37,27 @@
 /* Driver local variables and types.                                         */
 /*===========================================================================*/
 
+__attribute__ ((section(".cfmconfig")))
+const uint8_t _cfm[0x10] = {
+  0xFF,  /* NV_BACKKEY3: KEY=0xFF */
+  0xFF,  /* NV_BACKKEY2: KEY=0xFF */
+  0xFF,  /* NV_BACKKEY1: KEY=0xFF */
+  0xFF,  /* NV_BACKKEY0: KEY=0xFF */
+  0xFF,  /* NV_BACKKEY7: KEY=0xFF */
+  0xFF,  /* NV_BACKKEY6: KEY=0xFF */
+  0xFF,  /* NV_BACKKEY5: KEY=0xFF */
+  0xFF,  /* NV_BACKKEY4: KEY=0xFF */
+  0xFF,  /* NV_FPROT3: PROT=0xFF */
+  0xFF,  /* NV_FPROT2: PROT=0xFF */
+  0xFF,  /* NV_FPROT1: PROT=0xFF */
+  0xFF,  /* NV_FPROT0: PROT=0xFF */
+  0x7E,  /* NV_FSEC: KEYEN=1,MEEN=3,FSLACC=3,SEC=2 */
+  0xFF,  /* NV_FOPT: ??=1,??=1,FAST_INIT=1,LPBOOT1=1,RESET_PIN_CFG=1,
+                      NMI_DIS=1,EZPORT_DIS=1,LPBOOT0=1 */
+  0xFF,
+  0xFF
+};
+
 /*===========================================================================*/
 /* Driver local functions.                                                   */
 /*===========================================================================*/
-- 
cgit v1.2.3