soc: nxp_kinetis: Refactor flash configuration field to a common place
Refactors the kinetis flash configuration field so it can be shared across all kinetis SoCs. Defaults are overridden for the k8x and ke1xf series to preserve values used prior to this refactoring. Signed-off-by: Maureen Helm <maureen.helm@nxp.com>
This commit is contained in:
parent
2bc700f66e
commit
f646f8d0cf
11 changed files with 82 additions and 180 deletions
|
@ -1,3 +1,5 @@
|
|||
# SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
zephyr_sources_ifdef(CONFIG_KINETIS_FLASH_CONFIG flash_configuration.c)
|
||||
|
||||
add_subdirectory(${SOC_SERIES})
|
||||
|
|
|
@ -122,6 +122,39 @@ config KINETIS_FLASH_CONFIG_OFFSET
|
|||
hex "Kinetis flash configuration field offset"
|
||||
default 0x400
|
||||
|
||||
config KINETIS_FLASH_CONFIG_FSEC
|
||||
hex "Flash security byte (FSEC)"
|
||||
range 0 0xff
|
||||
default 0xfe
|
||||
help
|
||||
Configures the reset value of the FSEC register, which includes
|
||||
backdoor key access, mass erase, factory access, and flash security
|
||||
options.
|
||||
|
||||
config KINETIS_FLASH_CONFIG_FOPT
|
||||
hex "Flash nonvolatile option byte (FOPT)"
|
||||
range 0 0xff
|
||||
default 0xff
|
||||
help
|
||||
Configures the reset value of the FOPT register, which includes boot,
|
||||
NMI, and EzPort options.
|
||||
|
||||
config KINETIS_FLASH_CONFIG_FEPROT
|
||||
hex "EEPROM protection byte (FEPROT)"
|
||||
range 0 0xff
|
||||
default 0xff
|
||||
help
|
||||
Configures the reset value of the FEPROT register for FlexNVM
|
||||
devices. For program flash only devices, this byte is reserved.
|
||||
|
||||
config KINETIS_FLASH_CONFIG_FDPROT
|
||||
hex "Data flash protection byte (FDPROT)"
|
||||
range 0 0xff
|
||||
default 0xff
|
||||
help
|
||||
Configures the reset value of the FDPROT register for FlexNVM
|
||||
devices. For program flash only devices, this byte is reserved.
|
||||
|
||||
endif # KINETIS_FLASH_CONFIG
|
||||
|
||||
endif # SOC_FAMILY_KINETIS
|
||||
|
|
33
soc/arm/nxp_kinetis/flash_configuration.c
Normal file
33
soc/arm/nxp_kinetis/flash_configuration.c
Normal file
|
@ -0,0 +1,33 @@
|
|||
/*
|
||||
* Copyright (c) 2019, NXP
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#include <kernel.h>
|
||||
#include <linker/sections.h>
|
||||
|
||||
u8_t __kinetis_flash_config_section __kinetis_flash_config[] = {
|
||||
/* Backdoor Comparison Key (unused) */
|
||||
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
|
||||
|
||||
/* Program flash protection; 1 bit/region - 0=protected, 1=unprotected
|
||||
*/
|
||||
0xFF, 0xFF, 0xFF, 0xFF,
|
||||
|
||||
/* Flash security register (FSEC) enables/disables backdoor key access,
|
||||
* mass erase, factory access, and flash security
|
||||
*/
|
||||
CONFIG_KINETIS_FLASH_CONFIG_FSEC,
|
||||
|
||||
/* Flash nonvolatile option register (FOPT) enables/disables NMI,
|
||||
* EzPort, and boot options
|
||||
*/
|
||||
CONFIG_KINETIS_FLASH_CONFIG_FOPT,
|
||||
|
||||
/* EEPROM protection register (FEPROT) for FlexNVM devices */
|
||||
CONFIG_KINETIS_FLASH_CONFIG_FEPROT,
|
||||
|
||||
/* Data flash protection register (FDPROT) for FlexNVM devices */
|
||||
CONFIG_KINETIS_FLASH_CONFIG_FDPROT,
|
||||
};
|
|
@ -18,7 +18,6 @@
|
|||
#include <init.h>
|
||||
#include <soc.h>
|
||||
#include <drivers/uart.h>
|
||||
#include <linker/sections.h>
|
||||
#include <fsl_common.h>
|
||||
#include <fsl_clock.h>
|
||||
#include <arch/cpu.h>
|
||||
|
@ -34,37 +33,6 @@
|
|||
|
||||
#define TIMESRC_OSCERCLK (2)
|
||||
|
||||
/*
|
||||
* K64F Flash configuration fields
|
||||
* These 16 bytes, which must be loaded to address 0x400, include default
|
||||
* protection and security settings.
|
||||
* They are loaded at reset to various Flash Memory module (FTFE) registers.
|
||||
*
|
||||
* The structure is:
|
||||
* -Backdoor Comparison Key for unsecuring the MCU - 8 bytes
|
||||
* -Program flash protection bytes, 4 bytes, written to FPROT0-3
|
||||
* -Flash security byte, 1 byte, written to FSEC
|
||||
* -Flash nonvolatile option byte, 1 byte, written to FOPT
|
||||
* -Reserved, 1 byte, (Data flash protection byte for FlexNVM)
|
||||
* -Reserved, 1 byte, (EEPROM protection byte for FlexNVM)
|
||||
*
|
||||
*/
|
||||
u8_t __kinetis_flash_config_section __kinetis_flash_config[] = {
|
||||
/* Backdoor Comparison Key (unused) */
|
||||
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
|
||||
/* Program flash protection; 1 bit/region - 0=protected, 1=unprotected
|
||||
*/
|
||||
0xFF, 0xFF, 0xFF, 0xFF,
|
||||
/*
|
||||
* Flash security: Backdoor key disabled, Mass erase enabled,
|
||||
* Factory access enabled, MCU is unsecure
|
||||
*/
|
||||
0xFE,
|
||||
/* Flash nonvolatile option: NMI enabled, EzPort enabled, Normal boot */
|
||||
0xFF,
|
||||
/* Reserved for FlexNVM feature (unsupported by this MCU) */
|
||||
0xFF, 0xFF};
|
||||
|
||||
static const osc_config_t oscConfig = {
|
||||
.freq = CONFIG_OSC_XTAL0_FREQ,
|
||||
.capLoad = 0,
|
||||
|
|
|
@ -15,6 +15,13 @@ config NUM_IRQS
|
|||
# must be >= the highest interrupt number used
|
||||
default 106
|
||||
|
||||
if KINETIS_FLASH_CONFIG
|
||||
|
||||
config KINETIS_FLASH_CONFIG_FOPT
|
||||
default 0x3f
|
||||
|
||||
endif # KINETIS_FLASH_CONFIG
|
||||
|
||||
if ADC
|
||||
|
||||
config ADC_MCUX_ADC16
|
||||
|
|
|
@ -29,28 +29,6 @@
|
|||
#define RUNM_VLPR (2)
|
||||
#define RUNM_HSRUN (3)
|
||||
|
||||
/*
|
||||
* K8x flash configuration fields
|
||||
* These 16 bytes, which must be loaded into flash memory at offset 0x400,
|
||||
* include default protection and security settings.
|
||||
* They are loaded at reset to various Flash Memory module (FTFA) registers.
|
||||
*/
|
||||
u8_t __kinetis_flash_config_section __kinetis_flash_config[] = {
|
||||
/* Backdoor Comparison Key (unused) */
|
||||
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
|
||||
/* Program flash protection */
|
||||
0xFF, 0xFF, 0xFF, 0xFF,
|
||||
/*
|
||||
* Flash security: Backdoor key disabled, Mass erase enabled,
|
||||
* Factory access enabled, MCU is unsecure
|
||||
*/
|
||||
0xFE,
|
||||
/* Flash nonvolatile option: NMI enabled, EzPort enabled, Normal boot */
|
||||
0x3F,
|
||||
/* Reserved for FlexNVM feature (unsupported by this MCU) */
|
||||
0xFF, 0xFF
|
||||
};
|
||||
|
||||
static const osc_config_t osc_config = {
|
||||
.freq = CONFIG_OSC_XTAL0_FREQ,
|
||||
.capLoad = 0,
|
||||
|
|
|
@ -15,6 +15,13 @@ config NUM_IRQS
|
|||
# must be >= the highest interrupt number used
|
||||
default 91
|
||||
|
||||
if KINETIS_FLASH_CONFIG
|
||||
|
||||
config KINETIS_FLASH_CONFIG_FOPT
|
||||
default 0x7d
|
||||
|
||||
endif # KINETIS_FLASH_CONFIG
|
||||
|
||||
if CLOCK_CONTROL
|
||||
|
||||
config CLOCK_CONTROL_MCUX_SCG
|
||||
|
|
|
@ -15,36 +15,6 @@
|
|||
#include <fsl_cache.h>
|
||||
#include <cortex_m/exc.h>
|
||||
|
||||
/*
|
||||
* KE1xF flash configuration fields
|
||||
* These 16 bytes, which must be loaded to address 0x400, include default
|
||||
* protection, boot options and security settings.
|
||||
* They are loaded at reset to various Flash Memory module (FTFE) registers.
|
||||
*/
|
||||
u8_t __kinetis_flash_config_section __kinetis_flash_config[] = {
|
||||
/* Backdoor Comparison Key (unused) */
|
||||
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
|
||||
/* Program flash protection */
|
||||
0xFF, 0xFF, 0xFF, 0xFF,
|
||||
/*
|
||||
* Flash security: Backdoor key disabled, Mass erase enabled,
|
||||
* Factory access enabled, MCU is unsecure
|
||||
*/
|
||||
0xFE,
|
||||
/*
|
||||
* Flash nonvolatile option: Boot from ROM with BOOTCFG0/NMI
|
||||
* pin low, boot from flash with
|
||||
* BOOTCFG0/NMI pin high, RESET_b
|
||||
* pin dedicated, NMI enabled,
|
||||
* normal boot
|
||||
*/
|
||||
0x7d,
|
||||
/* EEPROM protection */
|
||||
0xFF,
|
||||
/* Data flash protection */
|
||||
0xFF,
|
||||
};
|
||||
|
||||
#define ASSERT_WITHIN_RANGE(val, min, max, str) \
|
||||
BUILD_ASSERT_MSG(val >= min && val <= max, str)
|
||||
|
||||
|
|
|
@ -8,7 +8,6 @@
|
|||
#include <device.h>
|
||||
#include <init.h>
|
||||
#include <soc.h>
|
||||
#include <linker/sections.h>
|
||||
#include <fsl_common.h>
|
||||
#include <fsl_clock.h>
|
||||
#include <arch/cpu.h>
|
||||
|
@ -19,37 +18,6 @@
|
|||
* Variables
|
||||
******************************************************************************/
|
||||
|
||||
/*
|
||||
* KL25Z Flash configuration fields
|
||||
* These 16 bytes, which must be loaded to address 0x400, include default
|
||||
* protection and security settings.
|
||||
* They are loaded at reset to various Flash Memory module (FTFE) registers.
|
||||
*
|
||||
* The structure is:
|
||||
* -Backdoor Comparison Key for unsecuring the MCU - 8 bytes
|
||||
* -Program flash protection bytes, 4 bytes, written to FPROT0-3
|
||||
* -Flash security byte, 1 byte, written to FSEC
|
||||
* -Flash nonvolatile option byte, 1 byte, written to FOPT
|
||||
* -Reserved, 1 byte, (Data flash protection byte for FlexNVM)
|
||||
* -Reserved, 1 byte, (EEPROM protection byte for FlexNVM)
|
||||
*
|
||||
*/
|
||||
u8_t __kinetis_flash_config_section __kinetis_flash_config[] = {
|
||||
/* Backdoor Comparison Key (unused) */
|
||||
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
|
||||
/* Program flash protection; 1 bit/region - 0=protected, 1=unprotected
|
||||
*/
|
||||
0xFF, 0xFF, 0xFF, 0xFF,
|
||||
/*
|
||||
* Flash security: Backdoor key disabled, Mass erase enabled,
|
||||
* Factory access enabled, MCU is unsecure
|
||||
*/
|
||||
0xFE,
|
||||
/* Flash nonvolatile option: NMI enabled, EzPort enabled, Normal boot */
|
||||
0xFF,
|
||||
/* Reserved for FlexNVM feature (unsupported by this MCU) */
|
||||
0xFF, 0xFF};
|
||||
|
||||
static ALWAYS_INLINE void clkInit(void)
|
||||
{
|
||||
/*
|
||||
|
|
|
@ -11,7 +11,6 @@
|
|||
#include <init.h>
|
||||
#include <soc.h>
|
||||
#include <drivers/uart.h>
|
||||
#include <linker/sections.h>
|
||||
#include <fsl_common.h>
|
||||
#include <fsl_clock.h>
|
||||
#include <arch/cpu.h>
|
||||
|
@ -27,37 +26,6 @@
|
|||
|
||||
#define TIMESRC_OSCERCLK (2)
|
||||
|
||||
/*
|
||||
* KW2xD Flash configuration fields
|
||||
* These 16 bytes, which must be loaded to address 0x400, include default
|
||||
* protection and security settings.
|
||||
* They are loaded at reset to various Flash Memory module (FTFE) registers.
|
||||
*
|
||||
* The structure is:
|
||||
* -Backdoor Comparison Key for unsecuring the MCU - 8 bytes
|
||||
* -Program flash protection bytes, 4 bytes, written to FPROT0-3
|
||||
* -Flash security byte, 1 byte, written to FSEC
|
||||
* -Flash nonvolatile option byte, 1 byte, written to FOPT
|
||||
* -Reserved, 1 byte, (Data flash protection byte for FlexNVM)
|
||||
* -Reserved, 1 byte, (EEPROM protection byte for FlexNVM)
|
||||
*
|
||||
*/
|
||||
uint8_t __kinetis_flash_config_section __kinetis_flash_config[] = {
|
||||
/* Backdoor Comparison Key (unused) */
|
||||
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
|
||||
/* Program flash protection; 1 bit/region - 0=protected, 1=unprotected
|
||||
*/
|
||||
0xFF, 0xFF, 0xFF, 0xFF,
|
||||
/*
|
||||
* Flash security: Backdoor key disabled, Mass erase enabled,
|
||||
* Factory access enabled, MCU is unsecure
|
||||
*/
|
||||
0xFE,
|
||||
/* Flash nonvolatile option: NMI enabled, EzPort enabled, Normal boot */
|
||||
0xFF,
|
||||
/* Reserved for FlexNVM feature (unsupported by this MCU) */
|
||||
0xFF, 0xFF};
|
||||
|
||||
static const osc_config_t oscConfig = {
|
||||
.freq = CONFIG_OSC_XTAL0_FREQ,
|
||||
.capLoad = 0,
|
||||
|
|
|
@ -9,7 +9,6 @@
|
|||
#include <init.h>
|
||||
#include <soc.h>
|
||||
#include <drivers/uart.h>
|
||||
#include <linker/sections.h>
|
||||
#include <fsl_common.h>
|
||||
#include <fsl_clock.h>
|
||||
#include <arch/cpu.h>
|
||||
|
@ -22,37 +21,6 @@
|
|||
|
||||
#define CLKDIV1_DIVBY2 (1)
|
||||
|
||||
/*
|
||||
* KW41Z Flash configuration fields
|
||||
* These 16 bytes, which must be loaded to address 0x400, include default
|
||||
* protection and security settings.
|
||||
* They are loaded at reset to various Flash Memory module (FTFE) registers.
|
||||
*
|
||||
* The structure is:
|
||||
* -Backdoor Comparison Key for unsecuring the MCU - 8 bytes
|
||||
* -Program flash protection bytes, 4 bytes, written to FPROT0-3
|
||||
* -Flash security byte, 1 byte, written to FSEC
|
||||
* -Flash nonvolatile option byte, 1 byte, written to FOPT
|
||||
* -Reserved, 1 byte, (Data flash protection byte for FlexNVM)
|
||||
* -Reserved, 1 byte, (EEPROM protection byte for FlexNVM)
|
||||
*
|
||||
*/
|
||||
u8_t __kinetis_flash_config_section __kinetis_flash_config[] = {
|
||||
/* Backdoor Comparison Key (unused) */
|
||||
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
|
||||
/* Program flash protection; 1 bit/region - 0=protected, 1=unprotected
|
||||
*/
|
||||
0xFF, 0xFF, 0xFF, 0xFF,
|
||||
/*
|
||||
* Flash security: Backdoor key disabled, Mass erase enabled,
|
||||
* Factory access enabled, MCU is unsecure
|
||||
*/
|
||||
0xFE,
|
||||
/* Flash nonvolatile option: NMI enabled, EzPort enabled, Normal boot */
|
||||
0xFF,
|
||||
/* Reserved for FlexNVM feature (unsupported by this MCU) */
|
||||
0xFF, 0xFF};
|
||||
|
||||
static const osc_config_t oscConfig = {
|
||||
.freq = CONFIG_OSC_XTAL0_FREQ,
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue