OpenOCD
kinetis.c File Reference
Include dependency graph for kinetis.c:

Go to the source code of this file.

Data Structures

struct  kinetis_chip
 
struct  kinetis_flash_bank
 
struct  kinetis_type
 

Macros

#define FCF_ADDRESS   0x00000400
 
#define FCF_FDPROT   0xf
 
#define FCF_FOPT   0xd
 
#define FCF_FPROT   0x8
 
#define FCF_FSEC   0xc
 
#define FCF_SIZE   0x10
 
#define FLEXRAM   0x14000000
 
#define FMC_PFB01CR   0x4001f004
 
#define FTFX_CMD_BLOCKSTAT   0x00
 
#define FTFX_CMD_LWORDPROG   0x06
 
#define FTFX_CMD_MASSERASE   0x44
 
#define FTFX_CMD_PGMPART   0x80
 
#define FTFX_CMD_SECTERASE   0x09
 
#define FTFX_CMD_SECTSTAT   0x01
 
#define FTFX_CMD_SECTWRITE   0x0b
 
#define FTFX_CMD_SETFLEXRAM   0x81
 
#define FTFX_FCCOB3   0x40020004
 
#define FTFX_FCNFG   0x40020001
 
#define FTFX_FDPROT   0x40020017
 
#define FTFX_FPROT3   0x40020010
 
#define FTFX_FSTAT   0x40020000
 
#define KINETIS_K_REVID_MASK   0x0000F000
 
#define KINETIS_K_REVID_SHIFT   12
 
#define KINETIS_K_SDID_K10_M100   0x00000100
 
#define KINETIS_K_SDID_K10_M120   0x00000180
 
#define KINETIS_K_SDID_K10_M50   0x00000000
 
#define KINETIS_K_SDID_K10_M72   0x00000080
 
#define KINETIS_K_SDID_K11   0x00000220
 
#define KINETIS_K_SDID_K12   0x00000200
 
#define KINETIS_K_SDID_K20_M100   0x00000110
 
#define KINETIS_K_SDID_K20_M120   0x00000190
 
#define KINETIS_K_SDID_K20_M50   0x00000010
 
#define KINETIS_K_SDID_K20_M72   0x00000090
 
#define KINETIS_K_SDID_K21_M120   0x00000330
 
#define KINETIS_K_SDID_K21_M50   0x00000230
 
#define KINETIS_K_SDID_K22_M120   0x00000310
 
#define KINETIS_K_SDID_K22_M50   0x00000210
 
#define KINETIS_K_SDID_K30_M100   0x00000120
 
#define KINETIS_K_SDID_K30_M72   0x000000A0
 
#define KINETIS_K_SDID_K40_M100   0x00000130
 
#define KINETIS_K_SDID_K40_M72   0x000000B0
 
#define KINETIS_K_SDID_K50_M72   0x000000E0
 
#define KINETIS_K_SDID_K51_M72   0x000000F0
 
#define KINETIS_K_SDID_K53   0x00000170
 
#define KINETIS_K_SDID_K60_M100   0x00000140
 
#define KINETIS_K_SDID_K60_M150   0x000001C0
 
#define KINETIS_K_SDID_K70_M150   0x000001D0
 
#define KINETIS_K_SDID_TYPE_MASK   0x00000FF0
 
#define KINETIS_MAX_BANKS   4u
 
#define KINETIS_SDID_DIEID_K22FN128   0x00000680 /* smaller pflash with FTFA */
 
#define KINETIS_SDID_DIEID_K22FN256   0x00000A80
 
#define KINETIS_SDID_DIEID_K22FN512   0x00000E80
 
#define KINETIS_SDID_DIEID_K24FN1M   0x00000300 /* Detect Errata 7534 */
 
#define KINETIS_SDID_DIEID_K24FN256   0x00000700
 
#define KINETIS_SDID_DIEID_MASK   0x00000F80
 
#define KINETIS_SDID_FAMILYID_K0X   0x00000000
 
#define KINETIS_SDID_FAMILYID_K1X   0x10000000
 
#define KINETIS_SDID_FAMILYID_K2X   0x20000000
 
#define KINETIS_SDID_FAMILYID_K3X   0x30000000
 
#define KINETIS_SDID_FAMILYID_K4X   0x40000000
 
#define KINETIS_SDID_FAMILYID_K5X   0x50000000
 
#define KINETIS_SDID_FAMILYID_K6X   0x60000000
 
#define KINETIS_SDID_FAMILYID_K7X   0x70000000
 
#define KINETIS_SDID_FAMILYID_K8X   0x80000000
 
#define KINETIS_SDID_FAMILYID_KL8X   0x90000000
 
#define KINETIS_SDID_FAMILYID_MASK   0xF0000000
 
#define KINETIS_SDID_FAMILYID_SHIFT   28
 
#define KINETIS_SDID_K_SERIES_MASK   0x0000FFFF
 
#define KINETIS_SDID_PROJECTID_KE1XF   0x00000080
 
#define KINETIS_SDID_PROJECTID_KE1XZ   0x00000100
 
#define KINETIS_SDID_PROJECTID_MASK   KINETIS_SDID_DIEID_MASK
 
#define KINETIS_SDID_SERIESID_K   0x00000000
 
#define KINETIS_SDID_SERIESID_KE   0x00200000
 
#define KINETIS_SDID_SERIESID_KL   0x00100000
 
#define KINETIS_SDID_SERIESID_KV   0x00600000
 
#define KINETIS_SDID_SERIESID_KW   0x00500000
 
#define KINETIS_SDID_SERIESID_MASK   0x00F00000
 
#define KINETIS_SDID_SUBFAMID_KX0   0x00000000
 
#define KINETIS_SDID_SUBFAMID_KX1   0x01000000
 
#define KINETIS_SDID_SUBFAMID_KX2   0x02000000
 
#define KINETIS_SDID_SUBFAMID_KX3   0x03000000
 
#define KINETIS_SDID_SUBFAMID_KX4   0x04000000
 
#define KINETIS_SDID_SUBFAMID_KX5   0x05000000
 
#define KINETIS_SDID_SUBFAMID_KX6   0x06000000
 
#define KINETIS_SDID_SUBFAMID_KX7   0x07000000
 
#define KINETIS_SDID_SUBFAMID_KX8   0x08000000
 
#define KINETIS_SDID_SUBFAMID_MASK   0x0F000000
 
#define KINETIS_SDID_SUBFAMID_SHIFT   24
 
#define KINETIS_SOPT1_RAMSIZE_K24FN1M   0x0000B000
 
#define KINETIS_SOPT1_RAMSIZE_MASK   0x0000F000
 
#define MC_PMCTRL   0x4007E003
 
#define MCM_PLACR   0xF000300C
 
#define MDM_ACCESS_TIMEOUT   500 /* msec */
 
#define MDM_AP   1
 
#define MDM_CTRL_CORE_HOLD_RES   (1<<4)
 
#define MDM_CTRL_DBG_DIS   (1<<1)
 
#define MDM_CTRL_DBG_REQ   (1<<2)
 
#define MDM_CTRL_FMEIP   (1<<0)
 
#define MDM_CTRL_SYS_RES_REQ   (1<<3)
 
#define MDM_CTRL_VLLSX_DBG_ACK   (1<<6)
 
#define MDM_CTRL_VLLSX_DBG_REQ   (1<<5)
 
#define MDM_CTRL_VLLSX_STAT_ACK   (1<<7)
 
#define MDM_REG_CTRL   0x04
 
#define MDM_REG_ID   0xfc
 
#define MDM_REG_STAT   0x00
 
#define MDM_STAT_BACKDOOREN   (1<<6)
 
#define MDM_STAT_CORE_HALTED   (1<<16)
 
#define MDM_STAT_CORE_SLEEPDEEP   (1<<17)
 
#define MDM_STAT_CORESLEEPING   (1<<18)
 
#define MDM_STAT_FMEACK   (1<<0)
 
#define MDM_STAT_FMEEN   (1<<5)
 
#define MDM_STAT_FREADY   (1<<1)
 
#define MDM_STAT_LLSMODEXIT   (1<<9)
 
#define MDM_STAT_LPEN   (1<<7)
 
#define MDM_STAT_SYSRES   (1<<3)
 
#define MDM_STAT_SYSSEC   (1<<2)
 
#define MDM_STAT_VLLSXMODEXIT   (1<<10)
 
#define MDM_STAT_VLPEN   (1<<8)
 
#define MSCM_OCMDR0   0x40001400
 
#define PM_CTRL_RUNM_RUN   0x00
 
#define PM_STAT_RUN   0x01
 
#define PM_STAT_VLPR   0x04
 
#define PMC_REGSC   0x4007D002
 
#define SIM_BASE   0x40047000
 
#define SIM_BASE_KL28   0x40074000
 
#define SIM_COPC   0x40048100
 
#define SIM_FCFG1_OFFSET   0x104c
 
#define SIM_FCFG2_OFFSET   0x1050
 
#define SIM_SDID_OFFSET   0x1024
 
#define SIM_SOPT1_OFFSET   0x0000
 
#define SMC32_PMCTRL   0x4007E00C
 
#define SMC32_PMSTAT   0x4007E014
 
#define SMC_PMCTRL   0x4007E001
 
#define SMC_PMSTAT   0x4007E003
 
#define WDOG32_CS_OFFSET   0
 
#define WDOG32_KE1X   0x40052000
 
#define WDOG32_KL28   0x40076000
 
#define WDOG_BASE   0x40052000
 
#define WDOG_STCTRLH_OFFSET   0
 

Functions

 COMMAND_HANDLER (kinetis_check_flash_security_status)
 
 COMMAND_HANDLER (kinetis_create_banks_handler)
 
 COMMAND_HANDLER (kinetis_disable_wdog_handler)
 
 COMMAND_HANDLER (kinetis_fcf_source_handler)
 
 COMMAND_HANDLER (kinetis_fopt_handler)
 
 COMMAND_HANDLER (kinetis_mdm_halt)
 
 COMMAND_HANDLER (kinetis_mdm_mass_erase)
 
 COMMAND_HANDLER (kinetis_mdm_reset)
 
 COMMAND_HANDLER (kinetis_nvm_partition)
 
 FLASH_BANK_COMMAND_HANDLER (kinetis_flash_bank_command)
 
static int kinetis_auto_probe (struct flash_bank *bank)
 
static int kinetis_blank_check (struct flash_bank *bank)
 
static int kinetis_check_run_mode (struct kinetis_chip *k_chip)
 
static int kinetis_chip_options (struct kinetis_chip *k_chip, int argc, const char *argv[])
 
static int kinetis_create_missing_banks (struct kinetis_chip *k_chip)
 
static int kinetis_disable_wdog (struct kinetis_chip *k_chip)
 
static int kinetis_disable_wdog32 (struct target *target, uint32_t wdog_base)
 
static int kinetis_disable_wdog_algo (struct target *target, size_t code_size, const uint8_t *code, uint32_t wdog_base)
 
static int kinetis_disable_wdog_kx (struct target *target)
 
static int kinetis_erase (struct flash_bank *bank, unsigned int first, unsigned int last)
 
static int kinetis_fill_fcf (struct flash_bank *bank, uint8_t *fcf)
 
static void kinetis_free_driver_priv (struct flash_bank *bank)
 
static int kinetis_ftfx_clear_error (struct target *target)
 
static int kinetis_ftfx_command (struct target *target, uint8_t fcmd, uint32_t faddr, uint8_t fccob4, uint8_t fccob5, uint8_t fccob6, uint8_t fccob7, uint8_t fccob8, uint8_t fccob9, uint8_t fccoba, uint8_t fccobb, uint8_t *ftfx_fstat)
 
static int kinetis_ftfx_decode_error (uint8_t fstat)
 
static int kinetis_ftfx_prepare (struct target *target)
 
static struct kinetis_chipkinetis_get_chip (struct target *target)
 
static int kinetis_info (struct flash_bank *bank, struct command_invocation *cmd)
 
static void kinetis_invalidate_flash_cache (struct kinetis_chip *k_chip)
 
static int kinetis_make_ram_ready (struct target *target)
 
static int kinetis_mdm_poll_register (struct adiv5_dap *dap, unsigned reg, uint32_t mask, uint32_t value, uint32_t timeout_ms)
 
static int kinetis_mdm_read_register (struct adiv5_dap *dap, unsigned reg, uint32_t *result)
 
static int kinetis_mdm_write_register (struct adiv5_dap *dap, unsigned reg, uint32_t value)
 
static int kinetis_probe (struct flash_bank *bank)
 
static int kinetis_probe_chip (struct kinetis_chip *k_chip)
 
static int kinetis_protect (struct flash_bank *bank, int set, unsigned int first, unsigned int last)
 
static int kinetis_protect_check (struct flash_bank *bank)
 
static int kinetis_read_pmstat (struct kinetis_chip *k_chip, uint8_t *pmstat)
 
static int kinetis_write (struct flash_bank *bank, const uint8_t *buffer, uint32_t offset, uint32_t count)
 
static int kinetis_write_block (struct flash_bank *bank, const uint8_t *buffer, uint32_t offset, uint32_t wcount)
 
static int kinetis_write_inner (struct flash_bank *bank, const uint8_t *buffer, uint32_t offset, uint32_t count)
 
static int kinetis_write_sections (struct flash_bank *bank, const uint8_t *buffer, uint32_t offset, uint32_t count)
 

Variables

static bool allow_fcf_writes
 
static bool create_banks
 
static uint8_t fcf_fopt = 0xff
 
static const struct command_registration kinetis_command_handler []
 
static const struct command_registration kinetis_exec_command_handlers []
 
const struct flash_driver kinetis_flash
 
static const uint8_t kinetis_flash_write_code []
 
static const uint32_t kinetis_known_mdm_ids []
 
static const struct command_registration kinetis_security_command_handlers []
 
static const struct kinetis_type kinetis_types_old []
 

Macro Definition Documentation

◆ FCF_ADDRESS

#define FCF_ADDRESS   0x00000400

Definition at line 73 of file kinetis.c.

◆ FCF_FDPROT

#define FCF_FDPROT   0xf

Definition at line 77 of file kinetis.c.

◆ FCF_FOPT

#define FCF_FOPT   0xd

Definition at line 76 of file kinetis.c.

◆ FCF_FPROT

#define FCF_FPROT   0x8

Definition at line 74 of file kinetis.c.

◆ FCF_FSEC

#define FCF_FSEC   0xc

Definition at line 75 of file kinetis.c.

◆ FCF_SIZE

#define FCF_SIZE   0x10

Definition at line 78 of file kinetis.c.

◆ FLEXRAM

#define FLEXRAM   0x14000000

Definition at line 80 of file kinetis.c.

◆ FMC_PFB01CR

#define FMC_PFB01CR   0x4001f004

Definition at line 83 of file kinetis.c.

◆ FTFX_CMD_BLOCKSTAT

#define FTFX_CMD_BLOCKSTAT   0x00

Definition at line 119 of file kinetis.c.

◆ FTFX_CMD_LWORDPROG

#define FTFX_CMD_LWORDPROG   0x06

Definition at line 121 of file kinetis.c.

◆ FTFX_CMD_MASSERASE

#define FTFX_CMD_MASSERASE   0x44

Definition at line 124 of file kinetis.c.

◆ FTFX_CMD_PGMPART

#define FTFX_CMD_PGMPART   0x80

Definition at line 125 of file kinetis.c.

◆ FTFX_CMD_SECTERASE

#define FTFX_CMD_SECTERASE   0x09

Definition at line 122 of file kinetis.c.

◆ FTFX_CMD_SECTSTAT

#define FTFX_CMD_SECTSTAT   0x01

Definition at line 120 of file kinetis.c.

◆ FTFX_CMD_SECTWRITE

#define FTFX_CMD_SECTWRITE   0x0b

Definition at line 123 of file kinetis.c.

◆ FTFX_CMD_SETFLEXRAM

#define FTFX_CMD_SETFLEXRAM   0x81

Definition at line 126 of file kinetis.c.

◆ FTFX_FCCOB3

#define FTFX_FCCOB3   0x40020004

Definition at line 86 of file kinetis.c.

◆ FTFX_FCNFG

#define FTFX_FCNFG   0x40020001

Definition at line 85 of file kinetis.c.

◆ FTFX_FDPROT

#define FTFX_FDPROT   0x40020017

Definition at line 88 of file kinetis.c.

◆ FTFX_FPROT3

#define FTFX_FPROT3   0x40020010

Definition at line 87 of file kinetis.c.

◆ FTFX_FSTAT

#define FTFX_FSTAT   0x40020000

Definition at line 84 of file kinetis.c.

◆ KINETIS_K_REVID_MASK

#define KINETIS_K_REVID_MASK   0x0000F000

Definition at line 193 of file kinetis.c.

◆ KINETIS_K_REVID_SHIFT

#define KINETIS_K_REVID_SHIFT   12

Definition at line 194 of file kinetis.c.

◆ KINETIS_K_SDID_K10_M100

#define KINETIS_K_SDID_K10_M100   0x00000100

Definition at line 170 of file kinetis.c.

◆ KINETIS_K_SDID_K10_M120

#define KINETIS_K_SDID_K10_M120   0x00000180

Definition at line 171 of file kinetis.c.

◆ KINETIS_K_SDID_K10_M50

#define KINETIS_K_SDID_K10_M50   0x00000000

Definition at line 168 of file kinetis.c.

◆ KINETIS_K_SDID_K10_M72

#define KINETIS_K_SDID_K10_M72   0x00000080

Definition at line 169 of file kinetis.c.

◆ KINETIS_K_SDID_K11

#define KINETIS_K_SDID_K11   0x00000220

Definition at line 172 of file kinetis.c.

◆ KINETIS_K_SDID_K12

#define KINETIS_K_SDID_K12   0x00000200

Definition at line 173 of file kinetis.c.

◆ KINETIS_K_SDID_K20_M100

#define KINETIS_K_SDID_K20_M100   0x00000110

Definition at line 176 of file kinetis.c.

◆ KINETIS_K_SDID_K20_M120

#define KINETIS_K_SDID_K20_M120   0x00000190

Definition at line 177 of file kinetis.c.

◆ KINETIS_K_SDID_K20_M50

#define KINETIS_K_SDID_K20_M50   0x00000010

Definition at line 174 of file kinetis.c.

◆ KINETIS_K_SDID_K20_M72

#define KINETIS_K_SDID_K20_M72   0x00000090

Definition at line 175 of file kinetis.c.

◆ KINETIS_K_SDID_K21_M120

#define KINETIS_K_SDID_K21_M120   0x00000330

Definition at line 179 of file kinetis.c.

◆ KINETIS_K_SDID_K21_M50

#define KINETIS_K_SDID_K21_M50   0x00000230

Definition at line 178 of file kinetis.c.

◆ KINETIS_K_SDID_K22_M120

#define KINETIS_K_SDID_K22_M120   0x00000310

Definition at line 181 of file kinetis.c.

◆ KINETIS_K_SDID_K22_M50

#define KINETIS_K_SDID_K22_M50   0x00000210

Definition at line 180 of file kinetis.c.

◆ KINETIS_K_SDID_K30_M100

#define KINETIS_K_SDID_K30_M100   0x00000120

Definition at line 183 of file kinetis.c.

◆ KINETIS_K_SDID_K30_M72

#define KINETIS_K_SDID_K30_M72   0x000000A0

Definition at line 182 of file kinetis.c.

◆ KINETIS_K_SDID_K40_M100

#define KINETIS_K_SDID_K40_M100   0x00000130

Definition at line 185 of file kinetis.c.

◆ KINETIS_K_SDID_K40_M72

#define KINETIS_K_SDID_K40_M72   0x000000B0

Definition at line 184 of file kinetis.c.

◆ KINETIS_K_SDID_K50_M72

#define KINETIS_K_SDID_K50_M72   0x000000E0

Definition at line 186 of file kinetis.c.

◆ KINETIS_K_SDID_K51_M72

#define KINETIS_K_SDID_K51_M72   0x000000F0

Definition at line 187 of file kinetis.c.

◆ KINETIS_K_SDID_K53

#define KINETIS_K_SDID_K53   0x00000170

Definition at line 188 of file kinetis.c.

◆ KINETIS_K_SDID_K60_M100

#define KINETIS_K_SDID_K60_M100   0x00000140

Definition at line 189 of file kinetis.c.

◆ KINETIS_K_SDID_K60_M150

#define KINETIS_K_SDID_K60_M150   0x000001C0

Definition at line 190 of file kinetis.c.

◆ KINETIS_K_SDID_K70_M150

#define KINETIS_K_SDID_K70_M150   0x000001D0

Definition at line 191 of file kinetis.c.

◆ KINETIS_K_SDID_TYPE_MASK

#define KINETIS_K_SDID_TYPE_MASK   0x00000FF0

Definition at line 167 of file kinetis.c.

◆ KINETIS_MAX_BANKS

#define KINETIS_MAX_BANKS   4u

Definition at line 253 of file kinetis.c.

◆ KINETIS_SDID_DIEID_K22FN128

#define KINETIS_SDID_DIEID_K22FN128   0x00000680 /* smaller pflash with FTFA */

Definition at line 155 of file kinetis.c.

◆ KINETIS_SDID_DIEID_K22FN256

#define KINETIS_SDID_DIEID_K22FN256   0x00000A80

Definition at line 156 of file kinetis.c.

◆ KINETIS_SDID_DIEID_K22FN512

#define KINETIS_SDID_DIEID_K22FN512   0x00000E80

Definition at line 157 of file kinetis.c.

◆ KINETIS_SDID_DIEID_K24FN1M

#define KINETIS_SDID_DIEID_K24FN1M   0x00000300 /* Detect Errata 7534 */

Definition at line 160 of file kinetis.c.

◆ KINETIS_SDID_DIEID_K24FN256

#define KINETIS_SDID_DIEID_K24FN256   0x00000700

Definition at line 158 of file kinetis.c.

◆ KINETIS_SDID_DIEID_MASK

#define KINETIS_SDID_DIEID_MASK   0x00000F80

Definition at line 153 of file kinetis.c.

◆ KINETIS_SDID_FAMILYID_K0X

#define KINETIS_SDID_FAMILYID_K0X   0x00000000

Definition at line 217 of file kinetis.c.

◆ KINETIS_SDID_FAMILYID_K1X

#define KINETIS_SDID_FAMILYID_K1X   0x10000000

Definition at line 218 of file kinetis.c.

◆ KINETIS_SDID_FAMILYID_K2X

#define KINETIS_SDID_FAMILYID_K2X   0x20000000

Definition at line 219 of file kinetis.c.

◆ KINETIS_SDID_FAMILYID_K3X

#define KINETIS_SDID_FAMILYID_K3X   0x30000000

Definition at line 220 of file kinetis.c.

◆ KINETIS_SDID_FAMILYID_K4X

#define KINETIS_SDID_FAMILYID_K4X   0x40000000

Definition at line 221 of file kinetis.c.

◆ KINETIS_SDID_FAMILYID_K5X

#define KINETIS_SDID_FAMILYID_K5X   0x50000000

Definition at line 222 of file kinetis.c.

◆ KINETIS_SDID_FAMILYID_K6X

#define KINETIS_SDID_FAMILYID_K6X   0x60000000

Definition at line 223 of file kinetis.c.

◆ KINETIS_SDID_FAMILYID_K7X

#define KINETIS_SDID_FAMILYID_K7X   0x70000000

Definition at line 224 of file kinetis.c.

◆ KINETIS_SDID_FAMILYID_K8X

#define KINETIS_SDID_FAMILYID_K8X   0x80000000

Definition at line 225 of file kinetis.c.

◆ KINETIS_SDID_FAMILYID_KL8X

#define KINETIS_SDID_FAMILYID_KL8X   0x90000000

Definition at line 226 of file kinetis.c.

◆ KINETIS_SDID_FAMILYID_MASK

#define KINETIS_SDID_FAMILYID_MASK   0xF0000000

Definition at line 216 of file kinetis.c.

◆ KINETIS_SDID_FAMILYID_SHIFT

#define KINETIS_SDID_FAMILYID_SHIFT   28

Definition at line 215 of file kinetis.c.

◆ KINETIS_SDID_K_SERIES_MASK

#define KINETIS_SDID_K_SERIES_MASK   0x0000FFFF

Definition at line 151 of file kinetis.c.

◆ KINETIS_SDID_PROJECTID_KE1XF

#define KINETIS_SDID_PROJECTID_KE1XF   0x00000080

Definition at line 230 of file kinetis.c.

◆ KINETIS_SDID_PROJECTID_KE1XZ

#define KINETIS_SDID_PROJECTID_KE1XZ   0x00000100

Definition at line 231 of file kinetis.c.

◆ KINETIS_SDID_PROJECTID_MASK

#define KINETIS_SDID_PROJECTID_MASK   KINETIS_SDID_DIEID_MASK

Definition at line 229 of file kinetis.c.

◆ KINETIS_SDID_SERIESID_K

#define KINETIS_SDID_SERIESID_K   0x00000000

Definition at line 197 of file kinetis.c.

◆ KINETIS_SDID_SERIESID_KE

#define KINETIS_SDID_SERIESID_KE   0x00200000

Definition at line 199 of file kinetis.c.

◆ KINETIS_SDID_SERIESID_KL

#define KINETIS_SDID_SERIESID_KL   0x00100000

Definition at line 198 of file kinetis.c.

◆ KINETIS_SDID_SERIESID_KV

#define KINETIS_SDID_SERIESID_KV   0x00600000

Definition at line 201 of file kinetis.c.

◆ KINETIS_SDID_SERIESID_KW

#define KINETIS_SDID_SERIESID_KW   0x00500000

Definition at line 200 of file kinetis.c.

◆ KINETIS_SDID_SERIESID_MASK

#define KINETIS_SDID_SERIESID_MASK   0x00F00000

Definition at line 196 of file kinetis.c.

◆ KINETIS_SDID_SUBFAMID_KX0

#define KINETIS_SDID_SUBFAMID_KX0   0x00000000

Definition at line 205 of file kinetis.c.

◆ KINETIS_SDID_SUBFAMID_KX1

#define KINETIS_SDID_SUBFAMID_KX1   0x01000000

Definition at line 206 of file kinetis.c.

◆ KINETIS_SDID_SUBFAMID_KX2

#define KINETIS_SDID_SUBFAMID_KX2   0x02000000

Definition at line 207 of file kinetis.c.

◆ KINETIS_SDID_SUBFAMID_KX3

#define KINETIS_SDID_SUBFAMID_KX3   0x03000000

Definition at line 208 of file kinetis.c.

◆ KINETIS_SDID_SUBFAMID_KX4

#define KINETIS_SDID_SUBFAMID_KX4   0x04000000

Definition at line 209 of file kinetis.c.

◆ KINETIS_SDID_SUBFAMID_KX5

#define KINETIS_SDID_SUBFAMID_KX5   0x05000000

Definition at line 210 of file kinetis.c.

◆ KINETIS_SDID_SUBFAMID_KX6

#define KINETIS_SDID_SUBFAMID_KX6   0x06000000

Definition at line 211 of file kinetis.c.

◆ KINETIS_SDID_SUBFAMID_KX7

#define KINETIS_SDID_SUBFAMID_KX7   0x07000000

Definition at line 212 of file kinetis.c.

◆ KINETIS_SDID_SUBFAMID_KX8

#define KINETIS_SDID_SUBFAMID_KX8   0x08000000

Definition at line 213 of file kinetis.c.

◆ KINETIS_SDID_SUBFAMID_MASK

#define KINETIS_SDID_SUBFAMID_MASK   0x0F000000

Definition at line 204 of file kinetis.c.

◆ KINETIS_SDID_SUBFAMID_SHIFT

#define KINETIS_SDID_SUBFAMID_SHIFT   24

Definition at line 203 of file kinetis.c.

◆ KINETIS_SOPT1_RAMSIZE_K24FN1M

#define KINETIS_SOPT1_RAMSIZE_K24FN1M   0x0000B000

Definition at line 149 of file kinetis.c.

◆ KINETIS_SOPT1_RAMSIZE_MASK

#define KINETIS_SOPT1_RAMSIZE_MASK   0x0000F000

Definition at line 148 of file kinetis.c.

◆ MC_PMCTRL

#define MC_PMCTRL   0x4007E003

Definition at line 101 of file kinetis.c.

◆ MCM_PLACR

#define MCM_PLACR   0xF000300C

Definition at line 102 of file kinetis.c.

◆ MDM_ACCESS_TIMEOUT

#define MDM_ACCESS_TIMEOUT   500 /* msec */

Definition at line 383 of file kinetis.c.

◆ MDM_AP

#define MDM_AP   1

Definition at line 354 of file kinetis.c.

◆ MDM_CTRL_CORE_HOLD_RES

#define MDM_CTRL_CORE_HOLD_RES   (1<<4)

Definition at line 378 of file kinetis.c.

◆ MDM_CTRL_DBG_DIS

#define MDM_CTRL_DBG_DIS   (1<<1)

Definition at line 375 of file kinetis.c.

◆ MDM_CTRL_DBG_REQ

#define MDM_CTRL_DBG_REQ   (1<<2)

Definition at line 376 of file kinetis.c.

◆ MDM_CTRL_FMEIP

#define MDM_CTRL_FMEIP   (1<<0)

Definition at line 374 of file kinetis.c.

◆ MDM_CTRL_SYS_RES_REQ

#define MDM_CTRL_SYS_RES_REQ   (1<<3)

Definition at line 377 of file kinetis.c.

◆ MDM_CTRL_VLLSX_DBG_ACK

#define MDM_CTRL_VLLSX_DBG_ACK   (1<<6)

Definition at line 380 of file kinetis.c.

◆ MDM_CTRL_VLLSX_DBG_REQ

#define MDM_CTRL_VLLSX_DBG_REQ   (1<<5)

Definition at line 379 of file kinetis.c.

◆ MDM_CTRL_VLLSX_STAT_ACK

#define MDM_CTRL_VLLSX_STAT_ACK   (1<<7)

Definition at line 381 of file kinetis.c.

◆ MDM_REG_CTRL

#define MDM_REG_CTRL   0x04

Definition at line 357 of file kinetis.c.

◆ MDM_REG_ID

#define MDM_REG_ID   0xfc

Definition at line 358 of file kinetis.c.

◆ MDM_REG_STAT

#define MDM_REG_STAT   0x00

Definition at line 356 of file kinetis.c.

◆ MDM_STAT_BACKDOOREN

#define MDM_STAT_BACKDOOREN   (1<<6)

Definition at line 365 of file kinetis.c.

◆ MDM_STAT_CORE_HALTED

#define MDM_STAT_CORE_HALTED   (1<<16)

Definition at line 370 of file kinetis.c.

◆ MDM_STAT_CORE_SLEEPDEEP

#define MDM_STAT_CORE_SLEEPDEEP   (1<<17)

Definition at line 371 of file kinetis.c.

◆ MDM_STAT_CORESLEEPING

#define MDM_STAT_CORESLEEPING   (1<<18)

Definition at line 372 of file kinetis.c.

◆ MDM_STAT_FMEACK

#define MDM_STAT_FMEACK   (1<<0)

Definition at line 360 of file kinetis.c.

◆ MDM_STAT_FMEEN

#define MDM_STAT_FMEEN   (1<<5)

Definition at line 364 of file kinetis.c.

◆ MDM_STAT_FREADY

#define MDM_STAT_FREADY   (1<<1)

Definition at line 361 of file kinetis.c.

◆ MDM_STAT_LLSMODEXIT

#define MDM_STAT_LLSMODEXIT   (1<<9)

Definition at line 368 of file kinetis.c.

◆ MDM_STAT_LPEN

#define MDM_STAT_LPEN   (1<<7)

Definition at line 366 of file kinetis.c.

◆ MDM_STAT_SYSRES

#define MDM_STAT_SYSRES   (1<<3)

Definition at line 363 of file kinetis.c.

◆ MDM_STAT_SYSSEC

#define MDM_STAT_SYSSEC   (1<<2)

Definition at line 362 of file kinetis.c.

◆ MDM_STAT_VLLSXMODEXIT

#define MDM_STAT_VLLSXMODEXIT   (1<<10)

Definition at line 369 of file kinetis.c.

◆ MDM_STAT_VLPEN

#define MDM_STAT_VLPEN   (1<<8)

Definition at line 367 of file kinetis.c.

◆ MSCM_OCMDR0

#define MSCM_OCMDR0   0x40001400

Definition at line 82 of file kinetis.c.

◆ PM_CTRL_RUNM_RUN

#define PM_CTRL_RUNM_RUN   0x00

Definition at line 116 of file kinetis.c.

◆ PM_STAT_RUN

#define PM_STAT_RUN   0x01

Definition at line 114 of file kinetis.c.

◆ PM_STAT_VLPR

#define PM_STAT_VLPR   0x04

Definition at line 115 of file kinetis.c.

◆ PMC_REGSC

#define PMC_REGSC   0x4007D002

Definition at line 100 of file kinetis.c.

◆ SIM_BASE

#define SIM_BASE   0x40047000

Definition at line 89 of file kinetis.c.

◆ SIM_BASE_KL28

#define SIM_BASE_KL28   0x40074000

Definition at line 90 of file kinetis.c.

◆ SIM_COPC

#define SIM_COPC   0x40048100

Definition at line 91 of file kinetis.c.

◆ SIM_FCFG1_OFFSET

#define SIM_FCFG1_OFFSET   0x104c

Definition at line 107 of file kinetis.c.

◆ SIM_FCFG2_OFFSET

#define SIM_FCFG2_OFFSET   0x1050

Definition at line 108 of file kinetis.c.

◆ SIM_SDID_OFFSET

#define SIM_SDID_OFFSET   0x1024

Definition at line 106 of file kinetis.c.

◆ SIM_SOPT1_OFFSET

#define SIM_SOPT1_OFFSET   0x0000

Definition at line 105 of file kinetis.c.

◆ SMC32_PMCTRL

#define SMC32_PMCTRL   0x4007E00C

Definition at line 98 of file kinetis.c.

◆ SMC32_PMSTAT

#define SMC32_PMSTAT   0x4007E014

Definition at line 99 of file kinetis.c.

◆ SMC_PMCTRL

#define SMC_PMCTRL   0x4007E001

Definition at line 96 of file kinetis.c.

◆ SMC_PMSTAT

#define SMC_PMSTAT   0x4007E003

Definition at line 97 of file kinetis.c.

◆ WDOG32_CS_OFFSET

#define WDOG32_CS_OFFSET   0

Definition at line 111 of file kinetis.c.

◆ WDOG32_KE1X

#define WDOG32_KE1X   0x40052000

Definition at line 94 of file kinetis.c.

◆ WDOG32_KL28

#define WDOG32_KL28   0x40076000

Definition at line 95 of file kinetis.c.

◆ WDOG_BASE

#define WDOG_BASE   0x40052000

Definition at line 93 of file kinetis.c.

◆ WDOG_STCTRLH_OFFSET

#define WDOG_STCTRLH_OFFSET   0

Definition at line 110 of file kinetis.c.

Function Documentation

◆ COMMAND_HANDLER() [1/9]

◆ COMMAND_HANDLER() [2/9]

COMMAND_HANDLER ( kinetis_create_banks_handler  )

Definition at line 3105 of file kinetis.c.

References CMD_ARGC, create_banks, ERROR_COMMAND_SYNTAX_ERROR, and ERROR_OK.

◆ COMMAND_HANDLER() [3/9]

COMMAND_HANDLER ( kinetis_disable_wdog_handler  )

◆ COMMAND_HANDLER() [4/9]

COMMAND_HANDLER ( kinetis_fcf_source_handler  )

◆ COMMAND_HANDLER() [5/9]

COMMAND_HANDLER ( kinetis_fopt_handler  )

◆ COMMAND_HANDLER() [6/9]

◆ COMMAND_HANDLER() [7/9]

◆ COMMAND_HANDLER() [8/9]

◆ COMMAND_HANDLER() [9/9]

◆ FLASH_BANK_COMMAND_HANDLER()

◆ kinetis_auto_probe()

static int kinetis_auto_probe ( struct flash_bank bank)
static

Definition at line 2819 of file kinetis.c.

References bank, ERROR_OK, kinetis_probe(), and kinetis_flash_bank::probed.

Referenced by kinetis_fill_fcf().

◆ kinetis_blank_check()

◆ kinetis_check_run_mode()

◆ kinetis_chip_options()

static int kinetis_chip_options ( struct kinetis_chip k_chip,
int  argc,
const char *  argv[] 
)
static

◆ kinetis_create_missing_banks()

◆ kinetis_disable_wdog()

◆ kinetis_disable_wdog32()

static int kinetis_disable_wdog32 ( struct target target,
uint32_t  wdog_base 
)
static

◆ kinetis_disable_wdog_algo()

◆ kinetis_disable_wdog_kx()

static int kinetis_disable_wdog_kx ( struct target target)
static

◆ kinetis_erase()

◆ kinetis_fill_fcf()

◆ kinetis_free_driver_priv()

static void kinetis_free_driver_priv ( struct flash_bank bank)
static

Definition at line 930 of file kinetis.c.

References bank, kinetis_flash_bank::k_chip, and kinetis_chip::num_banks.

◆ kinetis_ftfx_clear_error()

static int kinetis_ftfx_clear_error ( struct target target)
static

Definition at line 1224 of file kinetis.c.

References FTFX_FSTAT, and target_write_u8().

Referenced by kinetis_blank_check(), and kinetis_ftfx_prepare().

◆ kinetis_ftfx_command()

static int kinetis_ftfx_command ( struct target target,
uint8_t  fcmd,
uint32_t  faddr,
uint8_t  fccob4,
uint8_t  fccob5,
uint8_t  fccob6,
uint8_t  fccob7,
uint8_t  fccob8,
uint8_t  fccob9,
uint8_t  fccoba,
uint8_t  fccobb,
uint8_t *  ftfx_fstat 
)
static

◆ kinetis_ftfx_decode_error()

static int kinetis_ftfx_decode_error ( uint8_t  fstat)
static

◆ kinetis_ftfx_prepare()

static int kinetis_ftfx_prepare ( struct target target)
static

◆ kinetis_get_chip()

static struct kinetis_chip* kinetis_get_chip ( struct target target)
static

◆ kinetis_info()

static int kinetis_info ( struct flash_bank bank,
struct command_invocation cmd 
)
static

◆ kinetis_invalidate_flash_cache()

static void kinetis_invalidate_flash_cache ( struct kinetis_chip k_chip)
static

◆ kinetis_make_ram_ready()

static int kinetis_make_ram_ready ( struct target target)
static

◆ kinetis_mdm_poll_register()

static int kinetis_mdm_poll_register ( struct adiv5_dap dap,
unsigned  reg,
uint32_t  mask,
uint32_t  value,
uint32_t  timeout_ms 
)
static

◆ kinetis_mdm_read_register()

static int kinetis_mdm_read_register ( struct adiv5_dap dap,
unsigned  reg,
uint32_t *  result 
)
static

◆ kinetis_mdm_write_register()

static int kinetis_mdm_write_register ( struct adiv5_dap dap,
unsigned  reg,
uint32_t  value 
)
static

◆ kinetis_probe()

◆ kinetis_probe_chip()

static int kinetis_probe_chip ( struct kinetis_chip k_chip)
static

Definition at line 2051 of file kinetis.c.

References ARRAY_SIZE, kinetis_chip::cache_type, create_banks, kinetis_chip::dflash_size, ERROR_FLASH_OPER_UNSUPPORTED, ERROR_OK, kinetis_chip::fcfg2_maxaddr0_shifted, kinetis_chip::fcfg2_maxaddr1_shifted, kinetis_chip::flash_support, FLEXRAM, kinetis_create_missing_banks(), KINETIS_K_REVID_MASK, KINETIS_K_REVID_SHIFT, KINETIS_K_SDID_K10_M100, KINETIS_K_SDID_K10_M120, KINETIS_K_SDID_K10_M50, KINETIS_K_SDID_K10_M72, KINETIS_K_SDID_K11, KINETIS_K_SDID_K12, KINETIS_K_SDID_K20_M100, KINETIS_K_SDID_K20_M120, KINETIS_K_SDID_K20_M50, KINETIS_K_SDID_K20_M72, KINETIS_K_SDID_K21_M120, KINETIS_K_SDID_K21_M50, KINETIS_K_SDID_K22_M120, KINETIS_K_SDID_K22_M50, KINETIS_K_SDID_K30_M100, KINETIS_K_SDID_K30_M72, KINETIS_K_SDID_K40_M100, KINETIS_K_SDID_K40_M72, KINETIS_K_SDID_K50_M72, KINETIS_K_SDID_K51_M72, KINETIS_K_SDID_K53, KINETIS_K_SDID_K60_M100, KINETIS_K_SDID_K60_M150, KINETIS_K_SDID_K70_M150, KINETIS_K_SDID_TYPE_MASK, KINETIS_SDID_DIEID_K22FN128, KINETIS_SDID_DIEID_K22FN256, KINETIS_SDID_DIEID_K22FN512, KINETIS_SDID_DIEID_K24FN1M, KINETIS_SDID_DIEID_K24FN256, KINETIS_SDID_DIEID_MASK, KINETIS_SDID_FAMILYID_K0X, KINETIS_SDID_FAMILYID_K1X, KINETIS_SDID_FAMILYID_K2X, KINETIS_SDID_FAMILYID_K3X, KINETIS_SDID_FAMILYID_K4X, KINETIS_SDID_FAMILYID_K5X, KINETIS_SDID_FAMILYID_K6X, KINETIS_SDID_FAMILYID_K8X, KINETIS_SDID_FAMILYID_KL8X, KINETIS_SDID_FAMILYID_MASK, KINETIS_SDID_FAMILYID_SHIFT, KINETIS_SDID_K_SERIES_MASK, KINETIS_SDID_PROJECTID_KE1XF, KINETIS_SDID_PROJECTID_KE1XZ, KINETIS_SDID_PROJECTID_MASK, KINETIS_SDID_SERIESID_K, KINETIS_SDID_SERIESID_KE, KINETIS_SDID_SERIESID_KL, KINETIS_SDID_SERIESID_KV, KINETIS_SDID_SERIESID_KW, KINETIS_SDID_SERIESID_MASK, KINETIS_SDID_SUBFAMID_KX0, KINETIS_SDID_SUBFAMID_KX1, KINETIS_SDID_SUBFAMID_KX2, KINETIS_SDID_SUBFAMID_KX3, KINETIS_SDID_SUBFAMID_KX4, KINETIS_SDID_SUBFAMID_KX5, KINETIS_SDID_SUBFAMID_KX6, KINETIS_SDID_SUBFAMID_KX7, KINETIS_SDID_SUBFAMID_KX8, KINETIS_SDID_SUBFAMID_MASK, KINETIS_SDID_SUBFAMID_SHIFT, KINETIS_SOPT1_RAMSIZE_K24FN1M, KINETIS_SOPT1_RAMSIZE_MASK, kinetis_types_old, LOG_DEBUG, LOG_ERROR, LOG_INFO, LOG_WARNING, kinetis_chip::max_flash_prog_size, kinetis_chip::name, name, kinetis_chip::num_nvm_blocks, kinetis_chip::num_pflash_blocks, kinetis_chip::nvm_base, kinetis_chip::nvm_sector_size, kinetis_chip::nvm_size, kinetis_chip::pflash_base, kinetis_chip::pflash_sector_size, kinetis_chip::pflash_size, kinetis_chip::probed, kinetis_chip::progr_accel_ram, SIM_BASE, kinetis_chip::sim_base, SIM_BASE_KL28, kinetis_chip::sim_fcfg1, SIM_FCFG1_OFFSET, kinetis_chip::sim_fcfg2, SIM_FCFG2_OFFSET, kinetis_chip::sim_sdid, SIM_SDID_OFFSET, SIM_SOPT1_OFFSET, kinetis_chip::sysmodectrlr_type, kinetis_chip::target, target_read_u32(), and kinetis_chip::watchdog_type.

Referenced by kinetis_disable_wdog(), and kinetis_probe().

◆ kinetis_protect()

static int kinetis_protect ( struct flash_bank bank,
int  set,
unsigned int  first,
unsigned int  last 
)
static

◆ kinetis_protect_check()

◆ kinetis_read_pmstat()

static int kinetis_read_pmstat ( struct kinetis_chip k_chip,
uint8_t *  pmstat 
)
static

◆ kinetis_write()

◆ kinetis_write_block()

◆ kinetis_write_inner()

◆ kinetis_write_sections()

Variable Documentation

◆ allow_fcf_writes

bool allow_fcf_writes
static

Definition at line 386 of file kinetis.c.

Referenced by COMMAND_HANDLER(), kinetis_erase(), kinetis_protect(), and kinetis_write().

◆ create_banks

bool create_banks
static

Definition at line 388 of file kinetis.c.

Referenced by COMMAND_HANDLER(), and kinetis_probe_chip().

◆ fcf_fopt

uint8_t fcf_fopt = 0xff
static

Definition at line 387 of file kinetis.c.

Referenced by COMMAND_HANDLER(), and kinetis_fill_fcf().

◆ kinetis_command_handler

const struct command_registration kinetis_command_handler[]
static
Initial value:
= {
{
.name = "kinetis",
.mode = COMMAND_ANY,
.help = "Kinetis flash controller commands",
.usage = "",
},
}
#define COMMAND_REGISTRATION_DONE
Use this as the last entry in an array of command_registration records.
Definition: command.h:247
@ COMMAND_ANY
Definition: command.h:42
static const struct command_registration kinetis_exec_command_handlers[]
Definition: kinetis.c:3148

Definition at line 3105 of file kinetis.c.

◆ kinetis_exec_command_handlers

const struct command_registration kinetis_exec_command_handlers[]
static

Definition at line 3105 of file kinetis.c.

◆ kinetis_flash

const struct flash_driver kinetis_flash
Initial value:
= {
.name = "kinetis",
.flash_bank_command = kinetis_flash_bank_command,
.erase = kinetis_erase,
.protect = kinetis_protect,
.write = kinetis_write,
.probe = kinetis_probe,
.auto_probe = kinetis_auto_probe,
.erase_check = kinetis_blank_check,
.protect_check = kinetis_protect_check,
.info = kinetis_info,
.free_driver_priv = kinetis_free_driver_priv,
}
int default_flash_read(struct flash_bank *bank, uint8_t *buffer, uint32_t offset, uint32_t count)
Provides default read implementation for flash memory.
static int kinetis_protect_check(struct flash_bank *bank)
Definition: kinetis.c:1377
static int kinetis_info(struct flash_bank *bank, struct command_invocation *cmd)
Definition: kinetis.c:2829
static int kinetis_blank_check(struct flash_bank *bank)
Definition: kinetis.c:2848
static int kinetis_probe(struct flash_bank *bank)
Definition: kinetis.c:2681
static int kinetis_protect(struct flash_bank *bank, int set, unsigned int first, unsigned int last)
Definition: kinetis.c:1354
static int kinetis_write(struct flash_bank *bank, const uint8_t *buffer, uint32_t offset, uint32_t count)
Definition: kinetis.c:1934
static int kinetis_auto_probe(struct flash_bank *bank)
Definition: kinetis.c:2819
static void kinetis_free_driver_priv(struct flash_bank *bank)
Definition: kinetis.c:930
static int kinetis_erase(struct flash_bank *bank, unsigned int first, unsigned int last)
Definition: kinetis.c:1648
static const struct command_registration kinetis_command_handler[]
Definition: kinetis.c:3196

Definition at line 388 of file kinetis.c.

Referenced by kinetis_create_missing_banks(), and kinetis_get_chip().

◆ kinetis_flash_write_code

const uint8_t kinetis_flash_write_code[]
static
Initial value:
= {
}

Definition at line 1258 of file kinetis.c.

Referenced by kinetis_write_block().

◆ kinetis_known_mdm_ids

const uint32_t kinetis_known_mdm_ids[]
static
Initial value:
= {
0x001C0000,
0x001C0020,
0x001C0030,
}

Definition at line 721 of file kinetis.c.

Referenced by COMMAND_HANDLER().

◆ kinetis_security_command_handlers

const struct command_registration kinetis_security_command_handlers[]
static

Definition at line 3105 of file kinetis.c.

◆ kinetis_types_old

const struct kinetis_type kinetis_types_old[]
static

Definition at line 1 of file kinetis.c.

Referenced by kinetis_probe_chip().