OpenOCD
|
Upper level of NOR flash framework. More...
Go to the source code of this file.
Functions | |
struct flash_sector * | alloc_block_array (uint32_t offset, uint32_t size, unsigned int num_blocks) |
Allocate and fill an array of sectors or protection blocks. More... | |
static int | compare_section (const void *a, const void *b) |
int | default_flash_blank_check (struct flash_bank *bank) |
Provides default erased-bank check handling. More... | |
void | default_flash_free_driver_priv (struct flash_bank *bank) |
Deallocates bank->driver_priv. More... | |
static int | default_flash_mem_blank_check (struct flash_bank *bank) |
int | default_flash_read (struct flash_bank *bank, uint8_t *buffer, uint32_t offset, uint32_t count) |
Provides default read implementation for flash memory. More... | |
int | default_flash_verify (struct flash_bank *bank, const uint8_t *buffer, uint32_t offset, uint32_t count) |
Provides default verify implementation for flash memory. More... | |
void | flash_bank_add (struct flash_bank *bank) |
Adds a new NOR bank to the global list of banks. More... | |
struct flash_bank * | flash_bank_list (void) |
int | flash_driver_erase (struct flash_bank *bank, unsigned int first, unsigned int last) |
int | flash_driver_protect (struct flash_bank *bank, int set, unsigned int first, unsigned int last) |
int | flash_driver_read (struct flash_bank *bank, uint8_t *buffer, uint32_t offset, uint32_t count) |
static int | flash_driver_unprotect (struct flash_bank *bank, unsigned int first, unsigned int last) |
int | flash_driver_verify (struct flash_bank *bank, const uint8_t *buffer, uint32_t offset, uint32_t count) |
int | flash_driver_write (struct flash_bank *bank, const uint8_t *buffer, uint32_t offset, uint32_t count) |
int | flash_erase_address_range (struct target *target, bool pad, target_addr_t addr, uint32_t length) |
Erases length bytes in the target flash, starting at addr. More... | |
void | flash_free_all_banks (void) |
Deallocates all flash banks. More... | |
unsigned int | flash_get_bank_count (void) |
static int | flash_iterate_address_range (struct target *target, char *pad_reason, target_addr_t addr, uint32_t length, bool iterate_protect_blocks, int(*callback)(struct flash_bank *bank, unsigned int first, unsigned int last)) |
static int | flash_iterate_address_range_inner (struct target *target, char *pad_reason, target_addr_t addr, uint32_t length, bool iterate_protect_blocks, int(*callback)(struct flash_bank *bank, unsigned int first, unsigned int last)) |
int | flash_unlock_address_range (struct target *target, target_addr_t addr, uint32_t length) |
int | flash_write (struct target *target, struct image *image, uint32_t *written, bool erase) |
Writes image into the target flash. More... | |
target_addr_t | flash_write_align_end (struct flash_bank *bank, target_addr_t addr) |
Get aligned end address of a flash write region. More... | |
target_addr_t | flash_write_align_start (struct flash_bank *bank, target_addr_t addr) |
Get aligned start address of a flash write region. More... | |
static bool | flash_write_check_gap (struct flash_bank *bank, target_addr_t addr1, target_addr_t addr2) |
Check if gap between sections is bigger than minimum required to discontinue flash write. More... | |
int | flash_write_unlock_verify (struct target *target, struct image *image, uint32_t *written, bool erase, bool unlock, bool write, bool verify) |
int | get_flash_bank_by_addr (struct target *target, target_addr_t addr, bool check, struct flash_bank **result_bank) |
Returns the flash bank located at a specified address. More... | |
int | get_flash_bank_by_name (const char *name, struct flash_bank **bank_result) |
Returns the flash bank specified by name, which matches the driver name and a suffix (option) specify the driver-specific bank number. More... | |
struct flash_bank * | get_flash_bank_by_name_noprobe (const char *name) |
Returns the flash bank specified by name, which matches the driver name and a suffix (option) specify the driver-specific bank number. More... | |
int | get_flash_bank_by_num (unsigned int num, struct flash_bank **bank) |
Returns the flash bank like get_flash_bank_by_name(), without probing. More... | |
struct flash_bank * | get_flash_bank_by_num_noprobe (unsigned int num) |
Returns the flash bank like get_flash_bank_by_num(), without probing. More... | |
Variables | |
static struct flash_bank * | flash_banks |
Upper level of NOR flash framework.
The lower level interfaces are to drivers. These upper level ones primarily support access from Tcl scripts or from GDB.
Definition in file flash/nor/core.c.
struct flash_sector* alloc_block_array | ( | uint32_t | offset, |
uint32_t | size, | ||
unsigned int | num_blocks | ||
) |
Allocate and fill an array of sectors or protection blocks.
offset | Offset of first block. |
size | Size of each block. |
num_blocks | Number of blocks in array. |
Definition at line 1002 of file flash/nor/core.c.
References flash_sector::is_erased, flash_sector::is_protected, NULL, flash_sector::offset, offset, flash_sector::size, and size.
Referenced by esirisc_flash_probe(), FLASH_BANK_COMMAND_HANDLER(), kinetis_probe(), nrf5_probe(), psoc4_probe(), rp2040_flash_probe(), rsl10_probe(), samd_probe(), same5_probe(), stm32l4_probe(), and stm32x_probe().
|
static |
Definition at line 637 of file flash/nor/core.c.
References imagesection::base_address.
Referenced by flash_write_unlock_verify().
int default_flash_blank_check | ( | struct flash_bank * | bank | ) |
Provides default erased-bank check handling.
Checks to see if the flash driver knows they are erased; if things look uncertain, this routine will call default_flash_mem_blank_check() to confirm.
Definition at line 380 of file flash/nor/core.c.
References target_memory_check_block::address, bank, default_flash_mem_blank_check(), ERROR_NOT_IMPLEMENTED, ERROR_OK, ERROR_TARGET_NOT_HALTED, LOG_ERROR, LOG_USER, target_memory_check_block::result, target_memory_check_block::size, target_blank_check_memory(), and TARGET_HALTED.
Referenced by at91sam7_erase_check(), and nrf5_erase_page().
void default_flash_free_driver_priv | ( | struct flash_bank * | bank | ) |
Deallocates bank->driver_priv.
Definition at line 210 of file flash/nor/core.c.
|
static |
Definition at line 333 of file flash/nor/core.c.
References bank, buffer, ERROR_OK, ERROR_TARGET_NOT_HALTED, LOG_ERROR, TARGET_HALTED, and target_read_memory().
Referenced by default_flash_blank_check().
int default_flash_read | ( | struct flash_bank * | bank, |
uint8_t * | buffer, | ||
uint32_t | offset, | ||
uint32_t | count | ||
) |
Provides default read implementation for flash memory.
bank | The bank to read. |
buffer | The data bytes read. |
offset | The offset into the chip to read. |
count | The number of bytes to read. |
Definition at line 121 of file flash/nor/core.c.
References bank, buffer, count, offset, and target_read_buffer().
Referenced by mdr_read().
int default_flash_verify | ( | struct flash_bank * | bank, |
const uint8_t * | buffer, | ||
uint32_t | offset, | ||
uint32_t | count | ||
) |
Provides default verify implementation for flash memory.
bank | The bank to verify. |
buffer | The data bytes to verify. |
offset | The offset into the chip to verify. |
count | The number of bytes to verify. |
Definition at line 142 of file flash/nor/core.c.
References bank, buffer, count, ERROR_FAIL, ERROR_OK, image_calculate_checksum(), LOG_DEBUG, offset, TARGET_ADDR_FMT, and target_checksum_memory().
Referenced by flash_driver_verify().
void flash_bank_add | ( | struct flash_bank * | bank | ) |
Adds a new NOR bank to the global list of banks.
bank | The bank that should be added. |
Definition at line 164 of file flash/nor/core.c.
References bank, flash_banks, and flash_bank::next.
Referenced by COMMAND_HANDLER(), kinetis_create_missing_banks(), and msp432_probe().
struct flash_bank* flash_bank_list | ( | void | ) |
Definition at line 183 of file flash/nor/core.c.
References flash_banks.
Referenced by COMMAND_HANDLER(), FLASH_BANK_COMMAND_HANDLER(), flash_init_drivers(), flash_set_dirty(), jim_flash_list(), kinetis_get_chip(), nrf5_get_chip(), and rsl10_get_chip().
int flash_driver_erase | ( | struct flash_bank * | bank, |
unsigned int | first, | ||
unsigned int | last | ||
) |
Definition at line 29 of file flash/nor/core.c.
References bank, ERROR_OK, and LOG_ERROR.
Referenced by COMMAND_HANDLER(), and flash_erase_address_range().
int flash_driver_protect | ( | struct flash_bank * | bank, |
int | set, | ||
unsigned int | first, | ||
unsigned int | last | ||
) |
Definition at line 41 of file flash/nor/core.c.
References bank, ERROR_FAIL, ERROR_FLASH_OPER_UNSUPPORTED, ERROR_OK, and LOG_ERROR.
Referenced by COMMAND_HANDLER(), flash_driver_unprotect(), and virtual_protect().
int flash_driver_read | ( | struct flash_bank * | bank, |
uint8_t * | buffer, | ||
uint32_t | offset, | ||
uint32_t | count | ||
) |
Definition at line 102 of file flash/nor/core.c.
References bank, buffer, count, ERROR_OK, LOG_DEBUG, LOG_ERROR, offset, and TARGET_ADDR_FMT.
Referenced by COMMAND_HANDLER().
|
static |
Definition at line 620 of file flash/nor/core.c.
References bank, and flash_driver_protect().
Referenced by flash_unlock_address_range().
int flash_driver_verify | ( | struct flash_bank * | bank, |
const uint8_t * | buffer, | ||
uint32_t | offset, | ||
uint32_t | count | ||
) |
Definition at line 127 of file flash/nor/core.c.
References bank, buffer, count, default_flash_verify(), ERROR_OK, LOG_ERROR, offset, and TARGET_ADDR_FMT.
Referenced by flash_write_unlock_verify().
int flash_driver_write | ( | struct flash_bank * | bank, |
const uint8_t * | buffer, | ||
uint32_t | offset, | ||
uint32_t | count | ||
) |
Definition at line 85 of file flash/nor/core.c.
References bank, buffer, count, ERROR_OK, LOG_ERROR, offset, and TARGET_ADDR_FMT.
Referenced by COMMAND_HANDLER(), and flash_write_unlock_verify().
int flash_erase_address_range | ( | struct target * | target, |
bool | pad, | ||
target_addr_t | addr, | ||
uint32_t | length | ||
) |
Erases length bytes in the target flash, starting at addr.
The range addr to addr + length - 1 must be strictly sector aligned, unless pad is true. Setting pad true extends the range, at beginning and/or end, if needed for sector alignment.
Definition at line 613 of file flash/nor/core.c.
References addr, flash_driver_erase(), flash_iterate_address_range(), length, and NULL.
Referenced by COMMAND_HANDLER(), flash_write_unlock_verify(), and gdb_v_packet().
void flash_free_all_banks | ( | void | ) |
Deallocates all flash banks.
Definition at line 216 of file flash/nor/core.c.
References bank, flash_banks, LOG_WARNING, flash_bank::next, and NULL.
Referenced by openocd_main().
unsigned int flash_get_bank_count | ( | void | ) |
Definition at line 201 of file flash/nor/core.c.
References flash_banks, and flash_bank::next.
Referenced by gdb_memory_map(), gdb_new_connection(), and gdb_query_packet().
|
static |
Definition at line 578 of file flash/nor/core.c.
References addr, flash_bank::base, ERROR_OK, flash_iterate_address_range_inner(), get_flash_bank_by_addr(), length, LOG_DEBUG, and flash_bank::size.
Referenced by flash_erase_address_range(), and flash_unlock_address_range().
|
static |
Definition at line 448 of file flash/nor/core.c.
References addr, flash_bank::base, ERROR_FLASH_BANK_INVALID, ERROR_FLASH_DST_BREAKS_ALIGNMENT, ERROR_OK, get_flash_bank_by_addr(), length, LOG_ERROR, LOG_WARNING, flash_bank::num_prot_blocks, flash_bank::num_sectors, flash_sector::offset, flash_bank::prot_blocks, flash_bank::sectors, flash_sector::size, flash_bank::size, and TARGET_ADDR_FMT.
Referenced by flash_iterate_address_range().
int flash_unlock_address_range | ( | struct target * | target, |
target_addr_t | addr, | ||
uint32_t | length | ||
) |
Definition at line 626 of file flash/nor/core.c.
References addr, flash_driver_unprotect(), flash_iterate_address_range(), and length.
Referenced by COMMAND_HANDLER(), and flash_write_unlock_verify().
Writes image into the target flash.
The written parameter will contain the
target | The target with the flash to be programmed. |
image | The image that will be programmed to flash. |
written | On return, contains the number of bytes written. |
erase | Indicates whether the flash driver should first erase the corresponding banks or sectors before programming. |
Definition at line 996 of file flash/nor/core.c.
References flash_write_unlock_verify().
Referenced by gdb_v_packet().
target_addr_t flash_write_align_end | ( | struct flash_bank * | bank, |
target_addr_t | addr | ||
) |
Get aligned end address of a flash write region.
Align end address of a flash write region according to bank requirements.
Definition at line 678 of file flash/nor/core.c.
References addr, bank, FLASH_WRITE_ALIGN_SECTOR, and offset.
Referenced by COMMAND_HANDLER(), flash_write_check_gap(), and flash_write_unlock_verify().
target_addr_t flash_write_align_start | ( | struct flash_bank * | bank, |
target_addr_t | addr | ||
) |
Get aligned start address of a flash write region.
Align start address of a flash write region according to bank requirements.
Definition at line 654 of file flash/nor/core.c.
References addr, bank, FLASH_WRITE_ALIGN_SECTOR, and offset.
Referenced by COMMAND_HANDLER(), flash_write_check_gap(), and flash_write_unlock_verify().
|
static |
Check if gap between sections is bigger than minimum required to discontinue flash write.
Definition at line 701 of file flash/nor/core.c.
References bank, flash_write_align_end(), flash_write_align_start(), FLASH_WRITE_CONTINUOUS, and FLASH_WRITE_GAP_SECTOR.
Referenced by flash_write_unlock_verify().
int flash_write_unlock_verify | ( | struct target * | target, |
struct image * | image, | ||
uint32_t * | written, | ||
bool | erase, | ||
bool | unlock, | ||
bool | write, | ||
bool | verify | ||
) |
Definition at line 730 of file flash/nor/core.c.
References flash_bank::base, imagesection::base_address, buffer, compare_section(), flash_bank::default_padded_value, ERROR_FAIL, ERROR_OK, flash_driver_verify(), flash_driver_write(), flash_erase_address_range(), flash_set_dirty(), flash_unlock_address_range(), flash_write_align_end(), flash_write_align_start(), flash_write_check_gap(), get_flash_bank_by_addr(), image_read_section(), LOG_DEBUG, LOG_ERROR, LOG_INFO, LOG_WARNING, flash_bank::name, image::num_sections, flash_bank::num_sectors, flash_sector::offset, image::sections, flash_bank::sectors, flash_sector::size, flash_bank::size, size, imagesection::size, TARGET_ADDR_FMT, flash_bank::write_end_alignment, and flash_bank::write_start_alignment.
Referenced by COMMAND_HANDLER(), and flash_write().
int get_flash_bank_by_addr | ( | struct target * | target, |
target_addr_t | addr, | ||
bool | check, | ||
struct flash_bank ** | result_bank | ||
) |
Returns the flash bank located at a specified address.
target | The target, presumed to contain one or more banks. |
addr | An address that is within the range of the bank. |
check | return ERROR_OK and result_bank NULL if the bank does not exist |
result_bank | The struct flash_bank located at addr, or NULL. |
Definition at line 300 of file flash/nor/core.c.
References addr, flash_driver::auto_probe, flash_bank::base, flash_bank::driver, ERROR_FAIL, ERROR_OK, flash_banks, LOG_ERROR, flash_bank::next, NULL, flash_bank::size, flash_bank::target, and TARGET_ADDR_FMT.
Referenced by COMMAND_HANDLER(), flash_iterate_address_range(), flash_iterate_address_range_inner(), and flash_write_unlock_verify().
int get_flash_bank_by_name | ( | const char * | name, |
struct flash_bank ** | bank_result | ||
) |
Returns the flash bank specified by name, which matches the driver name and a suffix (option) specify the driver-specific bank number.
The suffix consists of the '.' and the driver-specific bank number: when two str9x banks are defined, then 'str9x.1' refers to the second.
Definition at line 261 of file flash/nor/core.c.
References bank, ERROR_OK, get_flash_bank_by_name_noprobe(), LOG_ERROR, and name.
Referenced by COMMAND_HELPER().
struct flash_bank* get_flash_bank_by_name_noprobe | ( | const char * | name | ) |
Returns the flash bank specified by name, which matches the driver name and a suffix (option) specify the driver-specific bank number.
The suffix consists of the '.' and the driver-specific bank number: when two str9x banks are defined, then 'str9x.1' refers to the second.
Definition at line 243 of file flash/nor/core.c.
References bank, flash_banks, flash_driver_name_matches(), get_flash_name_index(), name, and NULL.
Referenced by COMMAND_HANDLER(), COMMAND_HELPER(), FLASH_BANK_COMMAND_HANDLER(), get_flash_bank_by_name(), and virtual_get_master_bank().
int get_flash_bank_by_num | ( | unsigned int | num, |
struct flash_bank ** | bank | ||
) |
Returns the flash bank like get_flash_bank_by_name(), without probing.
num | The flash bank number. |
bank | returned bank if fn returns ERROR_OK |
Definition at line 280 of file flash/nor/core.c.
References flash_driver::auto_probe, bank, flash_bank::driver, ERROR_FAIL, ERROR_OK, get_flash_bank_by_num_noprobe(), and LOG_ERROR.
Referenced by COMMAND_HELPER(), gdb_memory_map(), and gdb_new_connection().
struct flash_bank* get_flash_bank_by_num_noprobe | ( | unsigned int | num | ) |
Returns the flash bank like get_flash_bank_by_num(), without probing.
num | The flash bank number. |
Definition at line 188 of file flash/nor/core.c.
References flash_banks, LOG_ERROR, flash_bank::next, and NULL.
Referenced by COMMAND_HANDLER(), COMMAND_HELPER(), gdb_memory_map(), gdb_new_connection(), and get_flash_bank_by_num().
|
static |
Definition at line 27 of file flash/nor/core.c.
Referenced by flash_bank_add(), flash_bank_list(), flash_free_all_banks(), flash_get_bank_count(), get_flash_bank_by_addr(), get_flash_bank_by_name_noprobe(), and get_flash_bank_by_num_noprobe().