OpenOCD
|
Go to the source code of this file.
Data Structures | |
struct | stm32x_flash_bank |
struct | stm32x_options |
struct | stm32x_property_addr |
Macros | |
#define | FLASH_BSY (1 << 0) |
#define | FLASH_EOP (1 << 5) |
#define | FLASH_ERASE_TIMEOUT 100 |
#define | FLASH_LOCK (1 << 7) |
#define | FLASH_MER (1 << 2) |
#define | FLASH_OBL_LAUNCH (1 << 13) /* except stm32f1x series */ |
#define | FLASH_OPTER (1 << 5) |
#define | FLASH_OPTPG (1 << 4) |
#define | FLASH_OPTWRE (1 << 9) |
#define | FLASH_PER (1 << 1) |
#define | FLASH_PG (1 << 0) |
#define | FLASH_PGERR (1 << 2) |
#define | FLASH_REG_BASE_B0 0x40022000 |
#define | FLASH_REG_BASE_B1 0x40022040 |
#define | FLASH_STRT (1 << 6) |
#define | FLASH_WRITE_TIMEOUT 10 |
#define | FLASH_WRPRTERR (1 << 4) |
#define | KEY1 0x45670123 |
#define | KEY2 0xCDEF89AB |
#define | OPT_BFB2 5 /* dual flash bank only */ |
#define | OPT_ERROR 0 |
#define | OPT_RDRSTSTDBY 4 |
#define | OPT_RDRSTSTOP 3 |
#define | OPT_RDWDGSW 2 |
#define | OPT_READOUT 1 |
#define | STM32_FLASH_ACR 0x00 |
#define | STM32_FLASH_ACR_B0 0x40022000 |
#define | STM32_FLASH_AR 0x14 |
#define | STM32_FLASH_AR_B0 0x40022014 |
#define | STM32_FLASH_CR 0x10 |
#define | STM32_FLASH_CR_B0 0x40022010 |
#define | STM32_FLASH_KEYR 0x04 |
#define | STM32_FLASH_KEYR_B0 0x40022004 |
#define | STM32_FLASH_OBR 0x1C |
#define | STM32_FLASH_OBR_B0 0x4002201C |
#define | STM32_FLASH_OPTKEYR 0x08 |
#define | STM32_FLASH_OPTKEYR_B0 0x40022008 |
#define | STM32_FLASH_SR 0x0C |
#define | STM32_FLASH_SR_B0 0x4002200C |
#define | STM32_FLASH_WRPR 0x20 |
#define | STM32_FLASH_WRPR_B0 0x40022020 |
#define | STM32_OB_DATA0 0x1FFFF804 |
#define | STM32_OB_DATA1 0x1FFFF806 |
#define | STM32_OB_RDP 0x1FFFF800 |
#define | STM32_OB_USER 0x1FFFF802 |
#define | STM32_OB_WRP0 0x1FFFF808 |
#define | STM32_OB_WRP1 0x1FFFF80A |
#define | STM32_OB_WRP2 0x1FFFF80C |
#define | STM32_OB_WRP3 0x1FFFF80E |
Functions | |
COMMAND_HANDLER (stm32x_handle_lock_command) | |
COMMAND_HANDLER (stm32x_handle_mass_erase_command) | |
COMMAND_HANDLER (stm32x_handle_options_load_command) | |
COMMAND_HANDLER (stm32x_handle_options_read_command) | |
COMMAND_HANDLER (stm32x_handle_options_write_command) | |
COMMAND_HANDLER (stm32x_handle_unlock_command) | |
FLASH_BANK_COMMAND_HANDLER (stm32x_flash_bank_command) | |
static const char * | get_stm32f0_revision (uint16_t rev_id) |
static int | get_stm32x_info (struct flash_bank *bank, struct command_invocation *cmd) |
static int | stm32x_auto_probe (struct flash_bank *bank) |
static int | stm32x_check_operation_supported (struct flash_bank *bank) |
static int | stm32x_erase (struct flash_bank *bank, unsigned int first, unsigned int last) |
static int | stm32x_erase_options (struct flash_bank *bank) |
static int | stm32x_get_device_id (struct flash_bank *bank, uint32_t *device_id) |
static int | stm32x_get_flash_reg (struct flash_bank *bank, uint32_t reg) |
static int | stm32x_get_flash_size (struct flash_bank *bank, uint16_t *flash_size_in_kb) |
static int | stm32x_get_flash_status (struct flash_bank *bank, uint32_t *status) |
static int | stm32x_get_property_addr (struct target *target, struct stm32x_property_addr *addr) |
static int | stm32x_mass_erase (struct flash_bank *bank) |
static int | stm32x_probe (struct flash_bank *bank) |
static int | stm32x_protect (struct flash_bank *bank, int set, unsigned int first, unsigned int last) |
static int | stm32x_protect_check (struct flash_bank *bank) |
static int | stm32x_read_options (struct flash_bank *bank) |
static int | stm32x_wait_status_busy (struct flash_bank *bank, int timeout) |
static int | stm32x_write (struct flash_bank *bank, const uint8_t *buffer, uint32_t offset, uint32_t count) |
static int | stm32x_write_block (struct flash_bank *bank, const uint8_t *buffer, uint32_t address, uint32_t hwords_count) |
Writes a block to flash either using target algorithm or use fallback, host controlled halfword-by-halfword access. More... | |
static int | stm32x_write_block_async (struct flash_bank *bank, const uint8_t *buffer, uint32_t address, uint32_t hwords_count) |
static int | stm32x_write_block_riscv (struct flash_bank *bank, const uint8_t *buffer, uint32_t address, uint32_t hwords_count) |
static int | stm32x_write_options (struct flash_bank *bank) |
Variables | |
static const struct command_registration | stm32f1x_command_handlers [] |
static const struct command_registration | stm32f1x_exec_command_handlers [] |
const struct flash_driver | stm32f1x_flash |
#define FLASH_BSY (1 << 0) |
Definition at line 76 of file stm32f1x.c.
#define FLASH_EOP (1 << 5) |
Definition at line 79 of file stm32f1x.c.
#define FLASH_ERASE_TIMEOUT 100 |
Definition at line 98 of file stm32f1x.c.
#define FLASH_LOCK (1 << 7) |
Definition at line 70 of file stm32f1x.c.
#define FLASH_MER (1 << 2) |
Definition at line 66 of file stm32f1x.c.
#define FLASH_OBL_LAUNCH (1 << 13) /* except stm32f1x series */ |
Definition at line 72 of file stm32f1x.c.
#define FLASH_OPTER (1 << 5) |
Definition at line 68 of file stm32f1x.c.
#define FLASH_OPTPG (1 << 4) |
Definition at line 67 of file stm32f1x.c.
#define FLASH_OPTWRE (1 << 9) |
Definition at line 71 of file stm32f1x.c.
#define FLASH_PER (1 << 1) |
Definition at line 65 of file stm32f1x.c.
#define FLASH_PG (1 << 0) |
Definition at line 64 of file stm32f1x.c.
#define FLASH_PGERR (1 << 2) |
Definition at line 77 of file stm32f1x.c.
#define FLASH_REG_BASE_B0 0x40022000 |
Definition at line 27 of file stm32f1x.c.
#define FLASH_REG_BASE_B1 0x40022040 |
Definition at line 28 of file stm32f1x.c.
#define FLASH_STRT (1 << 6) |
Definition at line 69 of file stm32f1x.c.
#define FLASH_WRITE_TIMEOUT 10 |
Definition at line 97 of file stm32f1x.c.
#define FLASH_WRPRTERR (1 << 4) |
Definition at line 78 of file stm32f1x.c.
#define KEY1 0x45670123 |
Definition at line 92 of file stm32f1x.c.
#define KEY2 0xCDEF89AB |
Definition at line 93 of file stm32f1x.c.
#define OPT_BFB2 5 /* dual flash bank only */ |
Definition at line 88 of file stm32f1x.c.
#define OPT_ERROR 0 |
Definition at line 83 of file stm32f1x.c.
#define OPT_RDRSTSTDBY 4 |
Definition at line 87 of file stm32f1x.c.
#define OPT_RDRSTSTOP 3 |
Definition at line 86 of file stm32f1x.c.
#define OPT_RDWDGSW 2 |
Definition at line 85 of file stm32f1x.c.
#define OPT_READOUT 1 |
Definition at line 84 of file stm32f1x.c.
#define STM32_FLASH_ACR 0x00 |
Definition at line 30 of file stm32f1x.c.
#define STM32_FLASH_ACR_B0 0x40022000 |
Definition at line 42 of file stm32f1x.c.
#define STM32_FLASH_AR 0x14 |
Definition at line 35 of file stm32f1x.c.
#define STM32_FLASH_AR_B0 0x40022014 |
Definition at line 47 of file stm32f1x.c.
#define STM32_FLASH_CR 0x10 |
Definition at line 34 of file stm32f1x.c.
#define STM32_FLASH_CR_B0 0x40022010 |
Definition at line 46 of file stm32f1x.c.
#define STM32_FLASH_KEYR 0x04 |
Definition at line 31 of file stm32f1x.c.
#define STM32_FLASH_KEYR_B0 0x40022004 |
Definition at line 43 of file stm32f1x.c.
#define STM32_FLASH_OBR 0x1C |
Definition at line 36 of file stm32f1x.c.
#define STM32_FLASH_OBR_B0 0x4002201C |
Definition at line 48 of file stm32f1x.c.
#define STM32_FLASH_OPTKEYR 0x08 |
Definition at line 32 of file stm32f1x.c.
#define STM32_FLASH_OPTKEYR_B0 0x40022008 |
Definition at line 44 of file stm32f1x.c.
#define STM32_FLASH_SR 0x0C |
Definition at line 33 of file stm32f1x.c.
#define STM32_FLASH_SR_B0 0x4002200C |
Definition at line 45 of file stm32f1x.c.
#define STM32_FLASH_WRPR 0x20 |
Definition at line 37 of file stm32f1x.c.
#define STM32_FLASH_WRPR_B0 0x40022020 |
Definition at line 49 of file stm32f1x.c.
#define STM32_OB_DATA0 0x1FFFF804 |
Definition at line 55 of file stm32f1x.c.
#define STM32_OB_DATA1 0x1FFFF806 |
Definition at line 56 of file stm32f1x.c.
#define STM32_OB_RDP 0x1FFFF800 |
Definition at line 53 of file stm32f1x.c.
#define STM32_OB_USER 0x1FFFF802 |
Definition at line 54 of file stm32f1x.c.
#define STM32_OB_WRP0 0x1FFFF808 |
Definition at line 57 of file stm32f1x.c.
#define STM32_OB_WRP1 0x1FFFF80A |
Definition at line 58 of file stm32f1x.c.
#define STM32_OB_WRP2 0x1FFFF80C |
Definition at line 59 of file stm32f1x.c.
#define STM32_OB_WRP3 0x1FFFF80E |
Definition at line 60 of file stm32f1x.c.
COMMAND_HANDLER | ( | stm32x_handle_lock_command | ) |
Definition at line 1322 of file stm32f1x.c.
References bank, CALL_COMMAND_HANDLER, CMD, CMD_ARGC, command_print(), ERROR_COMMAND_SYNTAX_ERROR, ERROR_OK, ERROR_TARGET_NOT_HALTED, LOG_ERROR, NULL, stm32x_flash_bank::option_bytes, stm32x_options::rdp, target::state, stm32x_check_operation_supported(), stm32x_erase_options(), stm32x_write_options(), and TARGET_HALTED.
COMMAND_HANDLER | ( | stm32x_handle_mass_erase_command | ) |
Definition at line 1650 of file stm32f1x.c.
References bank, CALL_COMMAND_HANDLER, CMD, CMD_ARGC, command_print(), ERROR_COMMAND_SYNTAX_ERROR, ERROR_OK, and stm32x_mass_erase().
COMMAND_HANDLER | ( | stm32x_handle_options_load_command | ) |
Definition at line 1566 of file stm32f1x.c.
References bank, CALL_COMMAND_HANDLER, stm32x_flash_bank::can_load_options, CMD_ARGC, ERROR_COMMAND_SYNTAX_ERROR, ERROR_FAIL, ERROR_OK, ERROR_TARGET_NOT_HALTED, FLASH_LOCK, FLASH_OBL_LAUNCH, KEY1, KEY2, LOG_ERROR, target::state, STM32_FLASH_CR, STM32_FLASH_KEYR, stm32x_check_operation_supported(), stm32x_get_flash_reg(), TARGET_HALTED, and target_write_u32().
COMMAND_HANDLER | ( | stm32x_handle_options_read_command | ) |
Definition at line 1406 of file stm32f1x.c.
References bank, CALL_COMMAND_HANDLER, CMD, CMD_ARGC, command_print(), ERROR_COMMAND_SYNTAX_ERROR, ERROR_OK, ERROR_TARGET_NOT_HALTED, stm32x_flash_bank::has_dual_banks, LOG_ERROR, NULL, OPT_BFB2, OPT_ERROR, OPT_RDRSTSTDBY, OPT_RDRSTSTOP, OPT_RDWDGSW, OPT_READOUT, stm32x_flash_bank::option_offset, target::state, STM32_FLASH_OBR_B0, STM32_FLASH_WRPR_B0, stm32x_check_operation_supported(), TARGET_HALTED, target_read_u32(), and stm32x_flash_bank::user_data_offset.
COMMAND_HANDLER | ( | stm32x_handle_options_write_command | ) |
Definition at line 1472 of file stm32f1x.c.
References bank, CALL_COMMAND_HANDLER, stm32x_flash_bank::can_load_options, CMD, CMD_ARGC, CMD_ARGV, COMMAND_PARSE_NUMBER, command_print(), stm32x_options::data, ERROR_COMMAND_SYNTAX_ERROR, ERROR_OK, ERROR_TARGET_NOT_HALTED, stm32x_flash_bank::has_dual_banks, LOG_ERROR, NULL, stm32x_flash_bank::option_bytes, target::state, stm32x_check_operation_supported(), stm32x_erase_options(), stm32x_read_options(), stm32x_write_options(), TARGET_HALTED, and stm32x_options::user.
COMMAND_HANDLER | ( | stm32x_handle_unlock_command | ) |
Definition at line 1366 of file stm32f1x.c.
References bank, CALL_COMMAND_HANDLER, CMD, CMD_ARGC, command_print(), ERROR_COMMAND_SYNTAX_ERROR, ERROR_OK, ERROR_TARGET_NOT_HALTED, LOG_ERROR, NULL, target::state, stm32x_check_operation_supported(), stm32x_erase_options(), stm32x_write_options(), and TARGET_HALTED.
FLASH_BANK_COMMAND_HANDLER | ( | stm32x_flash_bank_command | ) |
Definition at line 128 of file stm32f1x.c.
References bank, stm32x_flash_bank::can_load_options, CMD_ARGC, ERROR_COMMAND_SYNTAX_ERROR, ERROR_OK, FLASH_REG_BASE_B0, stm32x_flash_bank::has_dual_banks, stm32x_flash_bank::probed, stm32x_flash_bank::register_base, and stm32x_flash_bank::user_bank_size.
|
static |
|
static |
Definition at line 1082 of file stm32f1x.c.
References bank, cmd, command_print_sameline(), ERROR_FAIL, ERROR_OK, get_stm32f0_revision(), NULL, and stm32x_get_device_id().
|
static |
Definition at line 1052 of file stm32f1x.c.
References bank, ERROR_OK, stm32x_flash_bank::probed, and stm32x_probe().
|
static |
Definition at line 204 of file stm32f1x.c.
References bank, ERROR_FLASH_OPERATION_FAILED, ERROR_OK, FLASH_REG_BASE_B0, LOG_ERROR, and stm32x_flash_bank::register_base.
Referenced by COMMAND_HANDLER(), stm32x_protect(), and stm32x_protect_check().
|
static |
Definition at line 366 of file stm32f1x.c.
References bank, ERROR_OK, ERROR_TARGET_NOT_HALTED, FLASH_ERASE_TIMEOUT, FLASH_LOCK, FLASH_PER, FLASH_STRT, KEY1, KEY2, LOG_ERROR, STM32_FLASH_AR, STM32_FLASH_CR, STM32_FLASH_KEYR, stm32x_get_flash_reg(), stm32x_mass_erase(), stm32x_wait_status_busy(), TARGET_HALTED, and target_write_u32().
|
static |
Definition at line 242 of file stm32f1x.c.
References bank, stm32x_flash_bank::default_rdp, ERROR_OK, FLASH_ERASE_TIMEOUT, FLASH_LOCK, FLASH_OPTER, FLASH_OPTWRE, FLASH_STRT, KEY1, KEY2, stm32x_flash_bank::option_bytes, stm32x_options::rdp, STM32_FLASH_CR_B0, STM32_FLASH_KEYR_B0, STM32_FLASH_OPTKEYR_B0, stm32x_read_options(), stm32x_wait_status_busy(), and target_write_u32().
Referenced by COMMAND_HANDLER(), and stm32x_protect().
|
static |
Definition at line 781 of file stm32f1x.c.
References addr, bank, stm32x_property_addr::device_id, ERROR_OK, stm32x_get_property_addr(), and target_read_u32().
Referenced by get_stm32x_info(), and stm32x_probe().
|
inlinestatic |
Definition at line 150 of file stm32f1x.c.
References bank, and stm32x_flash_bank::register_base.
Referenced by COMMAND_HANDLER(), stm32x_erase(), stm32x_get_flash_status(), stm32x_mass_erase(), stm32x_wait_status_busy(), stm32x_write(), and stm32x_write_block_riscv().
|
static |
Definition at line 793 of file stm32f1x.c.
References addr, bank, ERROR_OK, stm32x_get_property_addr(), and target_read_u16().
Referenced by stm32x_probe().
|
inlinestatic |
Definition at line 156 of file stm32f1x.c.
References bank, status, STM32_FLASH_SR, stm32x_get_flash_reg(), and target_read_u32().
Referenced by stm32x_wait_status_busy().
|
static |
Definition at line 739 of file stm32f1x.c.
References addr, CORTEX_M0_PARTNO, CORTEX_M23_PARTNO, CORTEX_M3_PARTNO, CORTEX_M4_PARTNO, cortex_m_get_partno_safe(), CORTEX_M_PARTNO_INVALID, ERROR_FAIL, ERROR_OK, ERROR_TARGET_NOT_EXAMINED, LOG_ERROR, target_address_bits(), target_type_name(), and target_was_examined().
Referenced by stm32x_get_device_id(), and stm32x_get_flash_size().
|
static |
Definition at line 1613 of file stm32f1x.c.
References bank, ERROR_OK, ERROR_TARGET_NOT_HALTED, FLASH_ERASE_TIMEOUT, FLASH_LOCK, FLASH_MER, FLASH_STRT, KEY1, KEY2, LOG_ERROR, target::state, STM32_FLASH_CR, STM32_FLASH_KEYR, stm32x_get_flash_reg(), stm32x_wait_status_busy(), TARGET_HALTED, and target_write_u32().
Referenced by COMMAND_HANDLER(), and stm32x_erase().
|
static |
Definition at line 805 of file stm32f1x.c.
References alloc_block_array(), bank, stm32x_flash_bank::can_load_options, stm32x_flash_bank::default_rdp, ERROR_FAIL, ERROR_OK, FLASH_REG_BASE_B0, FLASH_REG_BASE_B1, stm32x_flash_bank::has_dual_banks, LOG_INFO, LOG_WARNING, NULL, stm32x_flash_bank::option_offset, stm32x_flash_bank::ppage_size, stm32x_flash_bank::probed, stm32x_flash_bank::register_base, stm32x_get_device_id(), stm32x_get_flash_size(), stm32x_flash_bank::user_bank_size, and stm32x_flash_bank::user_data_offset.
Referenced by stm32x_auto_probe().
|
static |
Definition at line 414 of file stm32f1x.c.
References bank, ERROR_OK, ERROR_TARGET_NOT_HALTED, LOG_ERROR, stm32x_flash_bank::option_bytes, stm32x_options::protection, target::state, stm32x_check_operation_supported(), stm32x_erase_options(), stm32x_write_options(), and TARGET_HALTED.
|
static |
Definition at line 344 of file stm32f1x.c.
References bank, ERROR_OK, STM32_FLASH_WRPR_B0, stm32x_check_operation_supported(), and target_read_u32().
|
static |
Definition at line 218 of file stm32f1x.c.
References bank, stm32x_options::data, stm32x_flash_bank::default_rdp, ERROR_OK, OPT_READOUT, stm32x_flash_bank::option_bytes, stm32x_flash_bank::option_offset, stm32x_options::protection, stm32x_options::rdp, STM32_FLASH_OBR_B0, STM32_FLASH_WRPR_B0, target_read_u32(), stm32x_options::user, and stm32x_flash_bank::user_data_offset.
Referenced by COMMAND_HANDLER(), and stm32x_erase_options().
|
static |
Definition at line 162 of file stm32f1x.c.
References alive_sleep(), bank, ERROR_FLASH_BUSY, ERROR_FLASH_OPERATION_FAILED, ERROR_FLASH_PROTECTED, ERROR_OK, FLASH_BSY, FLASH_PGERR, FLASH_WRPRTERR, LOG_DEBUG, LOG_ERROR, status, STM32_FLASH_SR, stm32x_get_flash_reg(), stm32x_get_flash_status(), and target_write_u32().
Referenced by stm32x_erase(), stm32x_erase_options(), stm32x_mass_erase(), stm32x_write_block(), stm32x_write_block_async(), and stm32x_write_block_riscv().
|
static |
Definition at line 692 of file stm32f1x.c.
References bank, buffer, count, ERROR_OK, ERROR_TARGET_NOT_HALTED, FLASH_LOCK, FLASH_PG, KEY1, KEY2, LOG_ERROR, offset, STM32_FLASH_CR, STM32_FLASH_KEYR, stm32x_get_flash_reg(), stm32x_write_block(), TARGET_HALTED, and target_write_u32().
|
static |
Writes a block to flash either using target algorithm or use fallback, host controlled halfword-by-halfword access.
Flash controller must be unlocked before this call.
Definition at line 650 of file stm32f1x.c.
References bank, buffer, ERROR_OK, ERROR_TARGET_RESOURCE_NOT_AVAILABLE, is_arm(), LOG_WARNING, stm32x_wait_status_busy(), stm32x_write_block_async(), stm32x_write_block_riscv(), target_to_arm(), and target_write_memory().
Referenced by stm32x_write(), and stm32x_write_options().
|
static |
Definition at line 445 of file stm32f1x.c.
References working_area::address, ARM_MODE_THREAD, ARMV7M_COMMON_MAGIC, ARRAY_SIZE, 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, init_reg_param(), LOG_ERROR, LOG_WARNING, MAX, MIN, NULL, PARAM_IN_OUT, PARAM_OUT, stm32x_flash_bank::register_base, source, stm32x_wait_status_busy(), target_alloc_working_area(), target_free_working_area(), target_get_working_area_avail(), target_run_flash_async_algorithm(), target_write_buffer(), and reg_param::value.
Referenced by stm32x_write_block().
|
static |
Definition at line 543 of file stm32f1x.c.
References working_area::address, ARRAY_SIZE, bank, buf_get_u32(), buf_set_u32(), buffer, destroy_reg_param(), ERROR_OK, ERROR_TARGET_RESOURCE_NOT_AVAILABLE, init_reg_param(), LOG_ERROR, LOG_WARNING, MAX, MIN, NULL, PARAM_IN_OUT, PARAM_OUT, source, STM32_FLASH_SR, stm32x_get_flash_reg(), stm32x_wait_status_busy(), target_alloc_working_area(), target_free_working_area(), target_get_working_area_avail(), TARGET_PRIxADDR, target_run_algorithm(), target_write_buffer(), and reg_param::value.
Referenced by stm32x_write_block().
|
static |
Definition at line 289 of file stm32f1x.c.
References bank, stm32x_options::data, ERROR_OK, FLASH_LOCK, FLASH_OPTPG, FLASH_OPTWRE, KEY1, KEY2, NULL, stm32x_flash_bank::option_bytes, stm32x_options::protection, stm32x_options::rdp, STM32_FLASH_CR_B0, STM32_FLASH_KEYR_B0, STM32_FLASH_OPTKEYR_B0, STM32_OB_RDP, stm32x_write_block(), target_buffer_set_u16(), target_write_u32(), and stm32x_options::user.
Referenced by COMMAND_HANDLER(), and stm32x_protect().
|
static |
Definition at line 1650 of file stm32f1x.c.
|
static |
Definition at line 1650 of file stm32f1x.c.
const struct flash_driver stm32f1x_flash |
Definition at line 1650 of file stm32f1x.c.