OpenOCD
|
Go to the source code of this file.
Data Structures | |
struct | kinetis_ke_flash_bank |
Functions | |
COMMAND_HANDLER (kinetis_ke_check_flash_security_status) | |
COMMAND_HANDLER (kinetis_ke_disable_wdog_handler) | |
COMMAND_HANDLER (kinetis_ke_mdm_mass_erase) | |
FLASH_BANK_COMMAND_HANDLER (kinetis_ke_flash_bank_command) | |
static int | kinetis_ke_auto_probe (struct flash_bank *bank) |
static int | kinetis_ke_blank_check (struct flash_bank *bank) |
static int | kinetis_ke_erase (struct flash_bank *bank, unsigned int first, unsigned int last) |
static int | kinetis_ke_ftmrx_command (struct flash_bank *bank, uint8_t count, uint8_t *FCCOBIX, uint8_t *FCCOBHI, uint8_t *FCCOBLO, uint8_t *fstat) |
static int | kinetis_ke_info (struct flash_bank *bank, struct command_invocation *cmd) |
static int | kinetis_ke_mdm_poll_register (struct adiv5_dap *dap, unsigned int reg, uint32_t mask, uint32_t value) |
static int | kinetis_ke_mdm_read_register (struct adiv5_dap *dap, unsigned int reg, uint32_t *result) |
static int | kinetis_ke_mdm_write_register (struct adiv5_dap *dap, unsigned int reg, uint32_t value) |
static int | kinetis_ke_prepare_flash (struct flash_bank *bank) |
static int | kinetis_ke_probe (struct flash_bank *bank) |
static int | kinetis_ke_protect (struct flash_bank *bank, int set, unsigned int first, unsigned int last) |
static int | kinetis_ke_protect_check (struct flash_bank *bank) |
static int | kinetis_ke_stop_watchdog (struct target *target) |
static int | kinetis_ke_write (struct flash_bank *bank, const uint8_t *buffer, uint32_t offset, uint32_t count) |
static int | kinetis_ke_write_words (struct flash_bank *bank, const uint8_t *buffer, uint32_t offset, uint32_t words) |
Variables | |
static const struct command_registration | kinetis_ke_command_handler [] |
static const struct command_registration | kinetis_ke_exec_command_handlers [] |
const struct flash_driver | kinetis_ke_flash |
static uint8_t | kinetis_ke_flash_write_code [] |
static const uint32_t | kinetis_ke_known_mdm_ids [] |
static const struct command_registration | kinetis_ke_security_command_handlers [] |
#define FTMRX_CMD_ALLERASED 0x01 |
Definition at line 68 of file kinetis_ke.c.
#define FTMRX_CMD_BLOCKERASED 0x02 |
Definition at line 69 of file kinetis_ke.c.
#define FTMRX_CMD_CONFIGNVM 0x0F |
Definition at line 81 of file kinetis_ke.c.
#define FTMRX_CMD_ERASEALL 0x08 |
Definition at line 74 of file kinetis_ke.c.
#define FTMRX_CMD_ERASEBLOCK 0x09 |
Definition at line 75 of file kinetis_ke.c.
#define FTMRX_CMD_ERASESECTOR 0x0A |
Definition at line 76 of file kinetis_ke.c.
#define FTMRX_CMD_PROGFLASH 0x06 |
Definition at line 72 of file kinetis_ke.c.
#define FTMRX_CMD_PROGONCE 0x07 |
Definition at line 73 of file kinetis_ke.c.
#define FTMRX_CMD_READONCE 0x04 |
Definition at line 71 of file kinetis_ke.c.
#define FTMRX_CMD_SECTIONERASED 0x03 |
Definition at line 70 of file kinetis_ke.c.
#define FTMRX_CMD_SETFACTORYLVL 0x0E |
Definition at line 80 of file kinetis_ke.c.
#define FTMRX_CMD_SETMARGINLVL 0x0D |
Definition at line 79 of file kinetis_ke.c.
#define FTMRX_CMD_UNSECURE 0x0B |
Definition at line 77 of file kinetis_ke.c.
#define FTMRX_CMD_VERIFYACCESS 0x0C |
Definition at line 78 of file kinetis_ke.c.
#define FTMRX_ERROR_ACCERR 0x20 |
Definition at line 84 of file kinetis_ke.c.
#define FTMRX_ERROR_FPVIOL 0x10 |
Definition at line 85 of file kinetis_ke.c.
#define FTMRX_FCLKDIV_FDIV | ( | x | ) | (((uint8_t)(((uint8_t)(x))<<FTMRX_FCLKDIV_FDIV_SHIFT))&FTMRX_FCLKDIV_FDIV_MASK) |
Definition at line 58 of file kinetis_ke.c.
#define FTMRX_FCLKDIV_FDIV_MASK 0x3F |
Definition at line 56 of file kinetis_ke.c.
#define FTMRX_FCLKDIV_FDIV_SHIFT 0 |
Definition at line 57 of file kinetis_ke.c.
#define FTMRX_FCLKDIV_FDIVLCK_MASK 0x40 |
Definition at line 59 of file kinetis_ke.c.
#define FTMRX_FCLKDIV_FDIVLCK_SHIFT 6 |
Definition at line 60 of file kinetis_ke.c.
#define FTMRX_FCLKDIV_FDIVLD_MASK 0x80 |
Definition at line 61 of file kinetis_ke.c.
#define FTMRX_FCLKDIV_FDIVLD_SHIFT 7 |
Definition at line 62 of file kinetis_ke.c.
#define FTMRX_FSTAT_CCIF_MASK 0x80 |
Definition at line 63 of file kinetis_ke.c.
#define FTMRX_FSTAT_MGSTAT0_MASK 0x01 |
Definition at line 64 of file kinetis_ke.c.
#define FTMRX_FSTAT_MGSTAT1_MASK 0x02 |
Definition at line 65 of file kinetis_ke.c.
#define ICS_C1 0x40064000 |
Definition at line 39 of file kinetis_ke.c.
#define ICS_C2 0x40064001 |
Definition at line 40 of file kinetis_ke.c.
#define ICS_C2_BDIV | ( | x | ) | (((uint8_t)(((uint8_t)(x))<<ICS_C2_BDIV_SHIFT))&ICS_C2_BDIV_MASK) |
Definition at line 52 of file kinetis_ke.c.
#define ICS_C2_BDIV_MASK 0xE0 |
Definition at line 50 of file kinetis_ke.c.
#define ICS_C2_BDIV_SHIFT 5 |
Definition at line 51 of file kinetis_ke.c.
#define ICS_C3 0x40064002 |
Definition at line 41 of file kinetis_ke.c.
#define ICS_C4 0x40064003 |
Definition at line 42 of file kinetis_ke.c.
#define ICS_C4_SCFTRIM_MASK 0x1 |
Definition at line 54 of file kinetis_ke.c.
#define ICS_S 0x40064004 |
Definition at line 43 of file kinetis_ke.c.
#define ICS_S_LOCK_MASK 0x40 |
Definition at line 53 of file kinetis_ke.c.
#define KINETIS_KE_SRSID_FAMID | ( | x | ) | ((x >> 28) & 0x0F) |
Definition at line 87 of file kinetis_ke.c.
#define KINETIS_KE_SRSID_KEX2 0x02 |
Definition at line 91 of file kinetis_ke.c.
#define KINETIS_KE_SRSID_KEX4 0x04 |
Definition at line 92 of file kinetis_ke.c.
#define KINETIS_KE_SRSID_KEX6 0x06 |
Definition at line 93 of file kinetis_ke.c.
#define KINETIS_KE_SRSID_PINCOUNT | ( | x | ) | ((x >> 16) & 0x0F) |
Definition at line 89 of file kinetis_ke.c.
#define KINETIS_KE_SRSID_SUBFAMID | ( | x | ) | ((x >> 24) & 0x0F) |
Definition at line 88 of file kinetis_ke.c.
#define MDM_ACCESS_TIMEOUT 3000 /* iterations */ |
Definition at line 135 of file kinetis_ke.c.
#define MDM_REG_CTRL 0x04 |
Definition at line 109 of file kinetis_ke.c.
#define MDM_REG_ID 0xfc |
Definition at line 110 of file kinetis_ke.c.
#define MDM_REG_STAT 0x00 |
Definition at line 108 of file kinetis_ke.c.
#define MDM_STAT_BACKDOOREN (1<<6) |
Definition at line 117 of file kinetis_ke.c.
#define MDM_STAT_CORE_HALTED (1<<16) |
Definition at line 122 of file kinetis_ke.c.
#define MDM_STAT_CORE_SLEEPDEEP (1<<17) |
Definition at line 123 of file kinetis_ke.c.
#define MDM_STAT_CORESLEEPING (1<<18) |
Definition at line 124 of file kinetis_ke.c.
#define MDM_STAT_FMEACK (1<<0) |
Definition at line 112 of file kinetis_ke.c.
#define MDM_STAT_FMEEN (1<<5) |
Definition at line 116 of file kinetis_ke.c.
#define MDM_STAT_FREADY (1<<1) |
Definition at line 113 of file kinetis_ke.c.
#define MDM_STAT_LLSMODEXIT (1<<9) |
Definition at line 120 of file kinetis_ke.c.
#define MDM_STAT_LPEN (1<<7) |
Definition at line 118 of file kinetis_ke.c.
#define MDM_STAT_SYSRES (1<<3) |
Definition at line 115 of file kinetis_ke.c.
#define MDM_STAT_SYSSEC (1<<2) |
Definition at line 114 of file kinetis_ke.c.
#define MDM_STAT_VLLSXMODEXIT (1<<10) |
Definition at line 121 of file kinetis_ke.c.
#define MDM_STAT_VLPEN (1<<8) |
Definition at line 119 of file kinetis_ke.c.
#define MEM_CTRL_CORE_HOLD_RES (1<<4) |
Definition at line 130 of file kinetis_ke.c.
#define MEM_CTRL_DBG_DIS (1<<1) |
Definition at line 127 of file kinetis_ke.c.
#define MEM_CTRL_DBG_REQ (1<<2) |
Definition at line 128 of file kinetis_ke.c.
#define MEM_CTRL_FMEIP (1<<0) |
Definition at line 126 of file kinetis_ke.c.
#define MEM_CTRL_SYS_RES_REQ (1<<3) |
Definition at line 129 of file kinetis_ke.c.
#define MEM_CTRL_VLLSX_DBG_ACK (1<<6) |
Definition at line 132 of file kinetis_ke.c.
#define MEM_CTRL_VLLSX_DBG_REQ (1<<5) |
Definition at line 131 of file kinetis_ke.c.
#define MEM_CTRL_VLLSX_STAT_ACK (1<<7) |
Definition at line 133 of file kinetis_ke.c.
#define SIM_BUSDIV 0x40048018 |
Definition at line 44 of file kinetis_ke.c.
#define SIM_CLKDIV_KE04_16_20_24 0x4004801C |
Definition at line 47 of file kinetis_ke.c.
#define SIM_CLKDIV_KE04_44_64_80 0x40048024 |
Definition at line 46 of file kinetis_ke.c.
#define SIM_CLKDIV_KE06 0x40048024 |
Definition at line 45 of file kinetis_ke.c.
#define SIM_CLKDIV_OUTDIV2_MASK 0x1000000 |
Definition at line 55 of file kinetis_ke.c.
#define SIM_SRSID 0x40048000 |
Definition at line 38 of file kinetis_ke.c.
#define WDOG_CS1 0x40052000 |
Definition at line 48 of file kinetis_ke.c.
COMMAND_HANDLER | ( | kinetis_ke_check_flash_security_status | ) |
Definition at line 581 of file kinetis_ke.c.
References armv7m_common::arm, cortex_m_common::armv7m, ARRAY_SIZE, CMD_CTX, arm::dap, ERROR_OK, get_current_target(), jtag_poll_set_enabled(), kinetis_ke_known_mdm_ids, kinetis_ke_mdm_poll_register(), kinetis_ke_mdm_read_register(), LOG_ERROR, LOG_INFO, LOG_WARNING, MDM_REG_ID, MDM_REG_STAT, MDM_STAT_FREADY, MDM_STAT_SYSSEC, and target_to_cm().
COMMAND_HANDLER | ( | kinetis_ke_disable_wdog_handler | ) |
Definition at line 494 of file kinetis_ke.c.
References CMD_ARGC, CMD_CTX, ERROR_COMMAND_SYNTAX_ERROR, get_current_target(), and kinetis_ke_stop_watchdog().
COMMAND_HANDLER | ( | kinetis_ke_mdm_mass_erase | ) |
Definition at line 504 of file kinetis_ke.c.
References adapter_assert_reset(), adapter_deassert_reset(), armv7m_common::arm, cortex_m_common::armv7m, CMD_CTX, arm::dap, ERROR_FAIL, ERROR_OK, get_current_target(), jtag_get_reset_config(), kinetis_ke_mdm_poll_register(), kinetis_ke_mdm_write_register(), LOG_ERROR, MDM_REG_CTRL, MDM_REG_STAT, MDM_STAT_FMEACK, MDM_STAT_FREADY, MDM_STAT_SYSRES, MEM_CTRL_FMEIP, MEM_CTRL_SYS_RES_REQ, RESET_HAS_SRST, and target_to_cm().
FLASH_BANK_COMMAND_HANDLER | ( | kinetis_ke_flash_bank_command | ) |
Definition at line 665 of file kinetis_ke.c.
References bank, CMD_ARGC, ERROR_COMMAND_SYNTAX_ERROR, ERROR_OK, and LOG_INFO.
|
static |
Definition at line 1133 of file kinetis_ke.c.
References bank, ERROR_OK, kinetis_ke_probe(), and kinetis_ke_flash_bank::sim_srsid.
|
static |
Definition at line 1151 of file kinetis_ke.c.
References bank, ERROR_OK, ERROR_TARGET_NOT_HALTED, FTMRX_CMD_ALLERASED, FTMRX_CMD_SECTIONERASED, FTMRX_FSTAT_MGSTAT0_MASK, FTMRX_FSTAT_MGSTAT1_MASK, kinetis_ke_ftmrx_command(), kinetis_ke_prepare_flash(), LOG_DEBUG, LOG_ERROR, NULL, and TARGET_HALTED.
|
static |
Definition at line 939 of file kinetis_ke.c.
References bank, ERROR_FLASH_OPERATION_FAILED, ERROR_OK, ERROR_TARGET_NOT_HALTED, FTMRX_CMD_ERASESECTOR, kinetis_ke_ftmrx_command(), kinetis_ke_prepare_flash(), LOG_ERROR, LOG_WARNING, and TARGET_HALTED.
|
static |
Definition at line 880 of file kinetis_ke.c.
References alive_sleep(), bank, count, ERROR_FLASH_OPERATION_FAILED, ERROR_OK, kinetis_ke_flash_bank::ftmrx_fccobhi_addr, kinetis_ke_flash_bank::ftmrx_fccobix_addr, kinetis_ke_flash_bank::ftmrx_fccoblo_addr, kinetis_ke_flash_bank::ftmrx_fstat_addr, FTMRX_FSTAT_CCIF_MASK, target_read_u8(), and target_write_u8().
Referenced by kinetis_ke_blank_check(), and kinetis_ke_erase().
|
static |
Definition at line 1143 of file kinetis_ke.c.
References bank, cmd, command_print_sameline(), ERROR_OK, and TARGET_ADDR_FMT.
|
static |
Definition at line 190 of file kinetis_ke.c.
References alive_sleep(), adiv5_ap::dap, ERROR_FAIL, ERROR_OK, kinetis_ke_mdm_read_register(), LOG_DEBUG, mask, and MDM_ACCESS_TIMEOUT.
Referenced by COMMAND_HANDLER().
|
static |
Definition at line 164 of file kinetis_ke.c.
References adiv5_ap::dap, dap_get_ap(), dap_put_ap(), dap_queue_ap_read(), dap_run(), ERROR_FAIL, ERROR_OK, and LOG_DEBUG.
Referenced by COMMAND_HANDLER(), and kinetis_ke_mdm_poll_register().
|
static |
Definition at line 137 of file kinetis_ke.c.
References adiv5_ap::dap, dap_get_ap(), dap_put_ap(), dap_queue_ap_write(), dap_run(), ERROR_FAIL, ERROR_OK, and LOG_DEBUG.
Referenced by COMMAND_HANDLER().
|
static |
Definition at line 208 of file kinetis_ke.c.
References alive_sleep(), bank, ERROR_FAIL, ERROR_FLASH_OPERATION_FAILED, ERROR_OK, kinetis_ke_flash_bank::ftmrx_fclkdiv_addr, FTMRX_FCLKDIV_FDIV, FTMRX_FCLKDIV_FDIV_MASK, FTMRX_FCLKDIV_FDIVLCK_MASK, FTMRX_FCLKDIV_FDIVLD_MASK, ICS_C1, ICS_C2, ICS_C2_BDIV, ICS_C2_BDIV_MASK, ICS_C3, ICS_C4, ICS_C4_SCFTRIM_MASK, ICS_S, ICS_S_LOCK_MASK, KINETIS_KE_SRSID_KEX2, KINETIS_KE_SRSID_KEX4, KINETIS_KE_SRSID_KEX6, KINETIS_KE_SRSID_PINCOUNT, KINETIS_KE_SRSID_SUBFAMID, LOG_ERROR, LOG_INFO, LOG_WARNING, SIM_BUSDIV, SIM_CLKDIV_KE04_16_20_24, SIM_CLKDIV_KE04_44_64_80, SIM_CLKDIV_KE06, SIM_CLKDIV_OUTDIV2_MASK, kinetis_ke_flash_bank::sim_srsid, target_read_u8(), target_write_u32(), and target_write_u8().
Referenced by kinetis_ke_blank_check(), kinetis_ke_erase(), and kinetis_ke_write().
|
static |
Definition at line 1038 of file kinetis_ke.c.
References bank, ERROR_FLASH_OPER_UNSUPPORTED, ERROR_OK, kinetis_ke_flash_bank::ftmrx_fccobhi_addr, kinetis_ke_flash_bank::ftmrx_fccobix_addr, kinetis_ke_flash_bank::ftmrx_fccoblo_addr, kinetis_ke_flash_bank::ftmrx_fclkdiv_addr, kinetis_ke_flash_bank::ftmrx_fprot_addr, kinetis_ke_flash_bank::ftmrx_fstat_addr, KINETIS_KE_SRSID_FAMID, KINETIS_KE_SRSID_KEX2, KINETIS_KE_SRSID_KEX4, KINETIS_KE_SRSID_KEX6, KINETIS_KE_SRSID_SUBFAMID, LOG_ERROR, LOG_INFO, offset, kinetis_ke_flash_bank::sector_size, SIM_SRSID, kinetis_ke_flash_bank::sim_srsid, and target_read_u32().
Referenced by kinetis_ke_auto_probe().
|
static |
Definition at line 771 of file kinetis_ke.c.
References bank, ERROR_FLASH_BANK_INVALID, ERROR_TARGET_NOT_HALTED, LOG_ERROR, LOG_WARNING, and TARGET_HALTED.
|
static |
Definition at line 785 of file kinetis_ke.c.
References bank, ERROR_OK, ERROR_TARGET_NOT_HALTED, kinetis_ke_flash_bank::ftmrx_fprot_addr, LOG_ERROR, LOG_WARNING, kinetis_ke_flash_bank::protection_size, kinetis_ke_flash_bank::sector_size, TARGET_HALTED, and target_read_u8().
|
static |
Definition at line 441 of file kinetis_ke.c.
References working_area::address, ARM_MODE_THREAD, ARMV7M_COMMON_MAGIC, armv7m_algorithm::common_magic, armv7m_algorithm::core_mode, ERROR_OK, ERROR_TARGET_NOT_HALTED, ERROR_TARGET_RESOURCE_NOT_AVAILABLE, LOG_ERROR, LOG_INFO, LOG_WARNING, NULL, target::state, target_alloc_working_area(), target_free_working_area(), TARGET_HALTED, target_read_u8(), target_run_algorithm(), target_write_buffer(), and WDOG_CS1.
Referenced by COMMAND_HANDLER(), and kinetis_ke_write().
|
static |
Definition at line 986 of file kinetis_ke.c.
References bank, buffer, count, ERROR_FAIL, ERROR_FLASH_BANK_INVALID, ERROR_FLASH_DST_BREAKS_ALIGNMENT, ERROR_OK, ERROR_TARGET_NOT_HALTED, kinetis_ke_prepare_flash(), kinetis_ke_stop_watchdog(), kinetis_ke_write_words(), LOG_ERROR, LOG_INFO, LOG_WARNING, NULL, offset, and TARGET_HALTED.
|
static |
Definition at line 688 of file kinetis_ke.c.
References working_area::address, ARM_MODE_THREAD, ARMV7M_COMMON_MAGIC, bank, buf_get_u32(), buf_set_u32(), buffer, armv7m_algorithm::common_magic, armv7m_algorithm::core_mode, destroy_reg_param(), ERROR_FLASH_OPERATION_FAILED, ERROR_OK, ERROR_TARGET_RESOURCE_NOT_AVAILABLE, FTMRX_ERROR_ACCERR, FTMRX_ERROR_FPVIOL, kinetis_ke_flash_bank::ftmrx_fccobhi_addr, kinetis_ke_flash_bank::ftmrx_fccobix_addr, kinetis_ke_flash_bank::ftmrx_fccoblo_addr, kinetis_ke_flash_bank::ftmrx_fstat_addr, init_reg_param(), kinetis_ke_flash_write_code, LOG_ERROR, LOG_INFO, LOG_WARNING, NULL, offset, PARAM_IN_OUT, PARAM_OUT, source, target_alloc_working_area(), target_free_working_area(), target_run_flash_async_algorithm(), and target_write_buffer().
Referenced by kinetis_ke_write().
|
static |
Definition at line 1151 of file kinetis_ke.c.
|
static |
Definition at line 1151 of file kinetis_ke.c.
const struct flash_driver kinetis_ke_flash |
Definition at line 1151 of file kinetis_ke.c.
|
static |
Definition at line 684 of file kinetis_ke.c.
Referenced by kinetis_ke_write_words().
|
static |
Definition at line 571 of file kinetis_ke.c.
Referenced by COMMAND_HANDLER().
|
static |
Definition at line 1151 of file kinetis_ke.c.