OpenOCD
|
Go to the source code of this file.
Data Structures | |
struct | samd_family |
struct | samd_info |
struct | samd_part |
Macros | |
#define | NVMUSERROW_LOCKBIT_MASK 0x0000FFFFFFFFFFFFULL |
#define | SAMD_CMDEX_KEY 0xA5UL |
#define | SAMD_DSU 0x41002000 /* Device Service Unit */ |
#define | SAMD_DSU_CTRL_EXT 0x100 /* CTRL register, external access */ |
#define | SAMD_DSU_DID 0x18 /* Device ID register */ |
#define | SAMD_DSU_STATUSA 1 /* DSU status register */ |
#define | SAMD_FAMILY_C 0x02 |
#define | SAMD_FAMILY_D 0x00 |
#define | SAMD_FAMILY_L 0x01 |
#define | SAMD_FLASH ((uint32_t)0x00000000) /* physical Flash memory */ |
#define | SAMD_GET_DEVSEL(id) (id & 0xFF) |
#define | SAMD_GET_FAMILY(id) (((id >> 23) & 0x1F)) |
#define | SAMD_GET_PROCESSOR(id) (id >> 28) |
#define | SAMD_GET_SERIES(id) (((id >> 16) & 0x3F)) |
#define | SAMD_NUM_PROT_BLOCKS 16 |
#define | SAMD_NVM_CMD(n) ((SAMD_CMDEX_KEY << 8) | (n & 0x7F)) |
#define | SAMD_NVM_CMD_CPRM 0x43 /* Clear Power Reduction Mode */ |
#define | SAMD_NVM_CMD_EAR 0x05 /* Erase Auxiliary Row */ |
#define | SAMD_NVM_CMD_ER 0x02 /* Erase Row */ |
#define | SAMD_NVM_CMD_INVALL 0x46 /* Invalidate all caches */ |
#define | SAMD_NVM_CMD_LR 0x40 /* Lock Region */ |
#define | SAMD_NVM_CMD_PBC 0x44 /* Page Buffer Clear */ |
#define | SAMD_NVM_CMD_SPRM 0x42 /* Set Power Reduction Mode */ |
#define | SAMD_NVM_CMD_SSB 0x45 /* Set Security Bit */ |
#define | SAMD_NVM_CMD_UR 0x41 /* Unlock Region */ |
#define | SAMD_NVM_CMD_WAP 0x06 /* Write Auxiliary Page */ |
#define | SAMD_NVM_CMD_WP 0x04 /* Write Page */ |
#define | SAMD_NVM_CTRLB_MANW 0x80 |
#define | SAMD_NVM_INTFLAG_READY 0x01 |
#define | SAMD_NVMCTRL 0x41004000 /* Non-volatile memory controller */ |
#define | SAMD_NVMCTRL_ADDR 0x1C /* NVM address register */ |
#define | SAMD_NVMCTRL_CTRLA 0x00 /* NVM control A register */ |
#define | SAMD_NVMCTRL_CTRLB 0x04 /* NVM control B register */ |
#define | SAMD_NVMCTRL_INTFLAG 0x14 /* NVM Interrupt Flag Status & Clear */ |
#define | SAMD_NVMCTRL_LOCK 0x20 /* NVM Lock section register */ |
#define | SAMD_NVMCTRL_PARAM 0x08 /* NVM parameters register */ |
#define | SAMD_NVMCTRL_STATUS 0x18 /* NVM status register */ |
#define | SAMD_PAC1 0x41000000 /* Peripheral Access Control 1 */ |
#define | SAMD_PAGE_SIZE_MAX 1024 |
#define | SAMD_PROCESSOR_M0 0x01 |
#define | SAMD_SERIES_09 0x04 |
#define | SAMD_SERIES_10 0x02 |
#define | SAMD_SERIES_11 0x03 |
#define | SAMD_SERIES_20 0x00 |
#define | SAMD_SERIES_21 0x01 |
#define | SAMD_SERIES_22 0x02 |
#define | SAMD_USER_ROW ((uint32_t)0x00804000) /* User Row of Flash */ |
Functions | |
COMMAND_HANDLER (samd_handle_bootloader_command) | |
COMMAND_HANDLER (samd_handle_chip_erase_command) | |
COMMAND_HANDLER (samd_handle_eeprom_command) | |
COMMAND_HANDLER (samd_handle_nvmuserrow_command) | |
COMMAND_HANDLER (samd_handle_reset_deassert) | |
COMMAND_HANDLER (samd_handle_set_security_command) | |
FLASH_BANK_COMMAND_HANDLER (samd_flash_bank_command) | |
static int | read_userrow (struct target *target, uint64_t *userrow) |
static int | samd_check_error (struct target *target) |
static int | samd_erase (struct flash_bank *bank, unsigned int first, unsigned int last) |
static int | samd_erase_row (struct target *target, uint32_t address) |
Erases a flash-row at the given address. More... | |
static const struct samd_family * | samd_find_family (uint32_t id) |
Gives the family structure to specific device id. More... | |
static const struct samd_part * | samd_find_part (uint32_t id) |
Gives the part structure to specific device id. More... | |
static int | samd_get_flash_page_info (struct target *target, uint32_t *sizep, int *nump) |
static int | samd_get_reservedmask (struct target *target, uint64_t *mask) |
Returns the bitmask of reserved bits in register. More... | |
static int | samd_issue_nvmctrl_command (struct target *target, uint16_t cmd) |
static int | samd_modify_user_row (struct target *target, uint64_t value, uint8_t startb, uint8_t endb) |
Modifies the user row register to the given value. More... | |
static int | samd_modify_user_row_masked (struct target *target, uint64_t value_input, uint64_t value_mask) |
Modify the contents of the User Row in Flash. More... | |
static int | samd_probe (struct flash_bank *bank) |
static int | samd_protect (struct flash_bank *bank, int set, unsigned int first, unsigned int last) |
static int | samd_protect_check (struct flash_bank *bank) |
static int | samd_write (struct flash_bank *bank, const uint8_t *buffer, uint32_t offset, uint32_t count) |
Variables | |
static const struct command_registration | at91samd_command_handlers [] |
static const struct command_registration | at91samd_exec_command_handlers [] |
const struct flash_driver | at91samd_flash |
static const struct samd_part | samc20_parts [] |
static const struct samd_part | samc21_parts [] |
static const struct samd_part | samd09_parts [] |
static const struct samd_part | samd10_parts [] |
static const struct samd_part | samd11_parts [] |
static const struct samd_part | samd20_parts [] |
static const struct samd_part | samd21_parts [] |
static const struct samd_family | samd_families [] |
static const struct samd_part | saml21_parts [] |
static const struct samd_part | saml22_parts [] |
#define NVMUSERROW_LOCKBIT_MASK 0x0000FFFFFFFFFFFFULL |
Definition at line 81 of file at91samd.c.
#define SAMD_CMDEX_KEY 0xA5UL |
Definition at line 40 of file at91samd.c.
#define SAMD_DSU 0x41002000 /* Device Service Unit */ |
Definition at line 25 of file at91samd.c.
#define SAMD_DSU_CTRL_EXT 0x100 /* CTRL register, external access */ |
Definition at line 30 of file at91samd.c.
#define SAMD_DSU_DID 0x18 /* Device ID register */ |
Definition at line 29 of file at91samd.c.
#define SAMD_DSU_STATUSA 1 /* DSU status register */ |
Definition at line 28 of file at91samd.c.
#define SAMD_FAMILY_C 0x02 |
Definition at line 66 of file at91samd.c.
#define SAMD_FAMILY_D 0x00 |
Definition at line 64 of file at91samd.c.
#define SAMD_FAMILY_L 0x01 |
Definition at line 65 of file at91samd.c.
#define SAMD_FLASH ((uint32_t)0x00000000) /* physical Flash memory */ |
Definition at line 22 of file at91samd.c.
Definition at line 78 of file at91samd.c.
Definition at line 76 of file at91samd.c.
Definition at line 75 of file at91samd.c.
Definition at line 77 of file at91samd.c.
#define SAMD_NUM_PROT_BLOCKS 16 |
Definition at line 19 of file at91samd.c.
#define SAMD_NVM_CMD | ( | n | ) | ((SAMD_CMDEX_KEY << 8) | (n & 0x7F)) |
Definition at line 41 of file at91samd.c.
#define SAMD_NVM_CMD_CPRM 0x43 /* Clear Power Reduction Mode */ |
Definition at line 51 of file at91samd.c.
#define SAMD_NVM_CMD_EAR 0x05 /* Erase Auxiliary Row */ |
Definition at line 46 of file at91samd.c.
#define SAMD_NVM_CMD_ER 0x02 /* Erase Row */ |
Definition at line 44 of file at91samd.c.
#define SAMD_NVM_CMD_INVALL 0x46 /* Invalidate all caches */ |
Definition at line 54 of file at91samd.c.
#define SAMD_NVM_CMD_LR 0x40 /* Lock Region */ |
Definition at line 48 of file at91samd.c.
#define SAMD_NVM_CMD_PBC 0x44 /* Page Buffer Clear */ |
Definition at line 52 of file at91samd.c.
#define SAMD_NVM_CMD_SPRM 0x42 /* Set Power Reduction Mode */ |
Definition at line 50 of file at91samd.c.
#define SAMD_NVM_CMD_SSB 0x45 /* Set Security Bit */ |
Definition at line 53 of file at91samd.c.
#define SAMD_NVM_CMD_UR 0x41 /* Unlock Region */ |
Definition at line 49 of file at91samd.c.
#define SAMD_NVM_CMD_WAP 0x06 /* Write Auxiliary Page */ |
Definition at line 47 of file at91samd.c.
#define SAMD_NVM_CMD_WP 0x04 /* Write Page */ |
Definition at line 45 of file at91samd.c.
#define SAMD_NVM_CTRLB_MANW 0x80 |
Definition at line 57 of file at91samd.c.
#define SAMD_NVM_INTFLAG_READY 0x01 |
Definition at line 60 of file at91samd.c.
#define SAMD_NVMCTRL 0x41004000 /* Non-volatile memory controller */ |
Definition at line 26 of file at91samd.c.
#define SAMD_NVMCTRL_ADDR 0x1C /* NVM address register */ |
Definition at line 37 of file at91samd.c.
#define SAMD_NVMCTRL_CTRLA 0x00 /* NVM control A register */ |
Definition at line 32 of file at91samd.c.
#define SAMD_NVMCTRL_CTRLB 0x04 /* NVM control B register */ |
Definition at line 33 of file at91samd.c.
#define SAMD_NVMCTRL_INTFLAG 0x14 /* NVM Interrupt Flag Status & Clear */ |
Definition at line 35 of file at91samd.c.
#define SAMD_NVMCTRL_LOCK 0x20 /* NVM Lock section register */ |
Definition at line 38 of file at91samd.c.
#define SAMD_NVMCTRL_PARAM 0x08 /* NVM parameters register */ |
Definition at line 34 of file at91samd.c.
#define SAMD_NVMCTRL_STATUS 0x18 /* NVM status register */ |
Definition at line 36 of file at91samd.c.
#define SAMD_PAC1 0x41000000 /* Peripheral Access Control 1 */ |
Definition at line 24 of file at91samd.c.
#define SAMD_PAGE_SIZE_MAX 1024 |
Definition at line 20 of file at91samd.c.
#define SAMD_PROCESSOR_M0 0x01 |
Definition at line 63 of file at91samd.c.
#define SAMD_SERIES_09 0x04 |
Definition at line 72 of file at91samd.c.
#define SAMD_SERIES_10 0x02 |
Definition at line 70 of file at91samd.c.
#define SAMD_SERIES_11 0x03 |
Definition at line 71 of file at91samd.c.
#define SAMD_SERIES_20 0x00 |
Definition at line 67 of file at91samd.c.
#define SAMD_SERIES_21 0x01 |
Definition at line 68 of file at91samd.c.
#define SAMD_SERIES_22 0x02 |
Definition at line 69 of file at91samd.c.
#define SAMD_USER_ROW ((uint32_t)0x00804000) /* User Row of Flash */ |
Definition at line 23 of file at91samd.c.
COMMAND_HANDLER | ( | samd_handle_bootloader_command | ) |
Definition at line 1119 of file at91samd.c.
References CMD, CMD_ARGC, CMD_ARGV, CMD_CTX, command_print(), ERROR_COMMAND_SYNTAX_ERROR, ERROR_OK, ERROR_TARGET_NOT_HALTED, get_current_target(), LOG_ERROR, NULL, samd_get_flash_page_info(), samd_modify_user_row(), SAMD_USER_ROW, size, target::state, TARGET_HALTED, and target_read_u16().
COMMAND_HANDLER | ( | samd_handle_chip_erase_command | ) |
Definition at line 967 of file at91samd.c.
References CMD, CMD_CTX, command_print(), ERROR_FAIL, ERROR_OK, get_current_target(), SAMD_DSU, SAMD_DSU_CTRL_EXT, SAMD_PAC1, target_write_u32(), and target_write_u8().
COMMAND_HANDLER | ( | samd_handle_eeprom_command | ) |
Definition at line 1017 of file at91samd.c.
References CMD, CMD_ARGC, CMD_ARGV, CMD_CTX, command_print(), ERROR_COMMAND_SYNTAX_ERROR, ERROR_OK, ERROR_TARGET_NOT_HALTED, get_current_target(), LOG_ERROR, samd_modify_user_row(), SAMD_USER_ROW, size, target::state, TARGET_HALTED, and target_read_u16().
COMMAND_HANDLER | ( | samd_handle_nvmuserrow_command | ) |
Definition at line 1069 of file at91samd.c.
References CMD, CMD_ARGC, CMD_ARGV, CMD_CTX, COMMAND_PARSE_NUMBER, command_print(), ERROR_COMMAND_SYNTAX_ERROR, ERROR_FAIL, ERROR_OK, ERROR_TARGET_NOT_HALTED, get_current_target(), LOG_ERROR, mask, NVMUSERROW_LOCKBIT_MASK, read_userrow(), samd_get_reservedmask(), samd_modify_user_row_masked(), target::state, and TARGET_HALTED.
COMMAND_HANDLER | ( | samd_handle_reset_deassert | ) |
Definition at line 1184 of file at91samd.c.
COMMAND_HANDLER | ( | samd_handle_set_security_command | ) |
Definition at line 989 of file at91samd.c.
References CMD, CMD_ARGC, CMD_ARGV, CMD_CTX, command_print(), ERROR_COMMAND_SYNTAX_ERROR, ERROR_OK, ERROR_TARGET_NOT_HALTED, get_current_target(), LOG_ERROR, samd_issue_nvmctrl_command(), SAMD_NVM_CMD_SSB, target::state, and TARGET_HALTED.
FLASH_BANK_COMMAND_HANDLER | ( | samd_flash_bank_command | ) |
Definition at line 942 of file at91samd.c.
References bank, ERROR_FAIL, ERROR_OK, LOG_ERROR, samd_info::probed, SAMD_FLASH, samd_info::target, and TARGET_ADDR_FMT.
|
static |
Definition at line 637 of file at91samd.c.
References buffer, ERROR_OK, SAMD_USER_ROW, target_buffer_get_u64(), and target_read_memory().
Referenced by COMMAND_HANDLER(), and samd_modify_user_row_masked().
|
static |
Definition at line 505 of file at91samd.c.
References ERROR_FLASH_OPER_UNSUPPORTED, ERROR_FLASH_OPERATION_FAILED, ERROR_FLASH_PROTECTED, ERROR_OK, keep_alive(), LOG_ERROR, SAMD_NVM_INTFLAG_READY, SAMD_NVMCTRL, SAMD_NVMCTRL_INTFLAG, SAMD_NVMCTRL_STATUS, status, target_read_u16(), target_read_u8(), target_write_u16(), and timeval_ms().
Referenced by samd_issue_nvmctrl_command(), samd_modify_user_row_masked(), and samd_write().
|
static |
Definition at line 798 of file at91samd.c.
References bank, ERROR_FLASH_BANK_NOT_PROBED, ERROR_OK, ERROR_TARGET_NOT_HALTED, LOG_ERROR, samd_info::probed, samd_erase_row(), samd_probe(), and TARGET_HALTED.
|
static |
Erases a flash-row at the given address.
target | Pointer to the target structure. |
address | The address of the row. |
Definition at line 590 of file at91samd.c.
References ERROR_FAIL, ERROR_OK, LOG_ERROR, samd_issue_nvmctrl_command(), SAMD_NVM_CMD_EAR, SAMD_NVM_CMD_ER, SAMD_NVMCTRL, SAMD_NVMCTRL_ADDR, SAMD_USER_ROW, and target_write_u32().
Referenced by samd_erase(), and samd_modify_user_row_masked().
|
static |
Gives the family structure to specific device id.
id | The id of the device. |
Definition at line 362 of file at91samd.c.
References ARRAY_SIZE, samd_family::family, NULL, samd_family::processor, samd_families, SAMD_GET_FAMILY, SAMD_GET_PROCESSOR, SAMD_GET_SERIES, and samd_family::series.
Referenced by samd_find_part(), and samd_get_reservedmask().
|
static |
Gives the part structure to specific device id.
id | The id of the device. |
Definition at line 383 of file at91samd.c.
References samd_family::family, NULL, samd_find_family(), and SAMD_GET_DEVSEL.
Referenced by samd_probe().
|
static |
Definition at line 415 of file at91samd.c.
References ERROR_OK, LOG_ERROR, SAMD_NVMCTRL, SAMD_NVMCTRL_PARAM, and target_read_u32().
Referenced by COMMAND_HANDLER(), samd_modify_user_row_masked(), and samd_probe().
|
static |
Returns the bitmask of reserved bits in register.
target | Pointer to the target structure. |
mask | Bitmask, 0 -> value stays untouched. |
Definition at line 617 of file at91samd.c.
References ERROR_FAIL, ERROR_OK, samd_family::family, id, LOG_ERROR, mask, SAMD_DSU, SAMD_DSU_DID, samd_find_family(), and target_read_u32().
Referenced by COMMAND_HANDLER().
|
static |
Definition at line 564 of file at91samd.c.
References cmd, ERROR_OK, ERROR_TARGET_NOT_HALTED, LOG_ERROR, samd_check_error(), SAMD_NVM_CMD, SAMD_NVMCTRL, SAMD_NVMCTRL_CTRLA, target::state, TARGET_HALTED, and target_write_u32().
Referenced by COMMAND_HANDLER(), samd_erase_row(), samd_modify_user_row_masked(), samd_protect(), and samd_write().
|
static |
Modifies the user row register to the given value.
target | Pointer to the target structure. |
value | The value to write. |
startb | The bit-offset by which the given value is shifted. |
endb | The bit-offset of the last bit in value to write. |
Definition at line 737 of file at91samd.c.
References mask, and samd_modify_user_row_masked().
Referenced by COMMAND_HANDLER(), and samd_protect().
|
static |
Modify the contents of the User Row in Flash.
The User Row itself has a size of one page and contains a combination of "fuses" and calibration data. Bits which have a value of zero in the mask will not be changed. Up to now devices only use the first 64 bits.
target | Pointer to the target structure. |
value_input | The value to write. |
value_mask | Bitmask, 0 -> value stays untouched. |
Definition at line 660 of file at91samd.c.
References ERROR_FAIL, ERROR_OK, LOG_ERROR, NULL, read_userrow(), samd_check_error(), samd_erase_row(), samd_get_flash_page_info(), samd_issue_nvmctrl_command(), SAMD_NVM_CMD_WAP, SAMD_NVM_CTRLB_MANW, SAMD_NVMCTRL, SAMD_NVMCTRL_CTRLB, SAMD_PAGE_SIZE_MAX, SAMD_USER_ROW, target_buffer_set_u64(), target_read_memory(), target_read_u32(), and target_write_memory().
Referenced by COMMAND_HANDLER(), and samd_modify_user_row().
|
static |
Definition at line 437 of file at91samd.c.
References alloc_block_array(), bank, ERROR_FAIL, ERROR_OK, id, LOG_ERROR, LOG_INFO, LOG_WARNING, samd_info::num_pages, samd_info::page_size, samd_info::probed, samd_info::prot_block_size, SAMD_DSU, SAMD_DSU_DID, samd_find_part(), samd_get_flash_page_info(), SAMD_NUM_PROT_BLOCKS, samd_protect_check(), samd_info::sector_size, and target_read_u32().
Referenced by samd_erase(), and samd_write().
|
static |
Definition at line 748 of file at91samd.c.
References bank, ERROR_OK, ERROR_TARGET_NOT_HALTED, LOG_ERROR, LOG_WARNING, samd_issue_nvmctrl_command(), samd_modify_user_row(), SAMD_NVM_CMD_LR, SAMD_NVM_CMD_UR, SAMD_NVMCTRL, SAMD_NVMCTRL_ADDR, samd_protect_check(), TARGET_HALTED, and target_write_u32().
|
static |
Definition at line 398 of file at91samd.c.
References bank, ERROR_OK, SAMD_NVMCTRL, SAMD_NVMCTRL_LOCK, and target_read_u16().
Referenced by samd_probe(), and samd_protect().
|
static |
Definition at line 828 of file at91samd.c.
References bank, buffer, count, ERROR_FAIL, ERROR_FLASH_BANK_NOT_PROBED, ERROR_OK, ERROR_TARGET_NOT_HALTED, LOG_ERROR, NULL, offset, samd_info::page_size, samd_info::probed, samd_check_error(), samd_issue_nvmctrl_command(), SAMD_NVM_CMD_PBC, SAMD_NVM_CMD_WP, SAMD_NVM_CTRLB_MANW, SAMD_NVMCTRL, SAMD_NVMCTRL_CTRLB, samd_probe(), TARGET_HALTED, target_read_u32(), and target_write_memory().
|
static |
Definition at line 1184 of file at91samd.c.
|
static |
Definition at line 1184 of file at91samd.c.
const struct flash_driver at91samd_flash |
Definition at line 1184 of file at91samd.c.
|
static |
Definition at line 1 of file at91samd.c.
|
static |
Definition at line 1 of file at91samd.c.
|
static |
Definition at line 1 of file at91samd.c.
|
static |
Definition at line 1 of file at91samd.c.
|
static |
Definition at line 1 of file at91samd.c.
|
static |
Definition at line 1 of file at91samd.c.
|
static |
Definition at line 1 of file at91samd.c.
|
static |
Definition at line 1 of file at91samd.c.
Referenced by samd_find_family().
|
static |
Definition at line 1 of file at91samd.c.
|
static |
Definition at line 1 of file at91samd.c.